面向对像(7day)
Posted wanchenxi
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了面向对像(7day)相关的知识,希望对你有一定的参考价值。
# # # x=3 # 在python中能开辟作用域的就是函数,类,还有模块 # # # # for i in range(10): # for循环不能开辟作用域,一定义就是全局的,还有if else也是不能 # x=55 # # def f(): # x=5 # y=4 # # print(x) # # # class A(): # c=3 # # # print(c) # def add(x,y): return x+y import re
http://www.cnblogs.com/yuanchenqi/articles/6766020.html
参考模块的博客
time模块参考博客
random模块
import random #print(random.random()) #print(random.randint(1,4)) #[1,4] #print(random.randrange(1,3)) #[1,3) # print(random.choice([11,26,3,4])) # print(random.sample([11,26,3,4],2)) #print(random.uniform(1,3)) # item=[1,23,33] # # random.shuffle(item) # print(item) # a-z A-Z def validate(): s="" for i in range(5): rNum=random.randint(0,9) r_alph=chr(random.randint(65,90)) ret=random.choice([str(rNum),r_alph]) s+=ret return s print(validate())
摘要算法
import hashlib m=hashlib.md5() m.update("alex".encode("utf8")) #534b44a19bf18d20b71ecc4eb77c572f print(m.hexdigest()) m.update("alex".encode("utf8")) #alexalex print(m.hexdigest()) n=hashlib.md5("salt".encode("utf8")) n.update(b"alexalex") print(n.hexdigest()) # m=hashlib.sha1()
os模块
import os # print(os.getcwd()) # # f=open("test.txt","w") # # os.chdir(r"C:\\Users\\Administrator\\PycharmProjects\\py_fullstack_s4\\day32") # cd # # f=open("test2.txt","w") # # print(os.getcwd()) #os.makedirs("aaaaa/bbb") #os.removedirs("aaaaa/bbb") #print(os.listdir(r"C:\\Users\\Administrator\\PycharmProjects\\py_fullstack_s4\\day33")) # print(os.stat(r"C:\\Users\\Administrator\\PycharmProjects\\py_fullstack_s4\\day33\\test.txt")) # # # \'\'\' # os.stat_result(st_mode=33206, st_ino=10133099161702379, st_dev=3233102476, st_nlink=1, st_uid=0, st_gid=0, st_size=0, st_atime=1493176560, st_mtime=1493176614, st_ctime=1493176560) # # \'\'\' # "yuan"+os.sep+"image" #print(os.name) #print(os.system("dir")) # abs=os.path.abspath("test.txt") # print(os.path.basename(abs)) # print(os.path.dirname(abs)) s1=r"C:\\Users\\Administrator\\PycharmProjects" s2=r"py_fullstack_s4\\day33" #print(s1+os.sep+s2) ret=os.path.join(s1,s2) # 推荐方式 print(ret)
以上是关于面向对像(7day)的主要内容,如果未能解决你的问题,请参考以下文章