import re print(re.match('^chenrong','chenronghua123')) # ^ 表示开头 #<_sre.SRE_Match object; span=(0, 8), match='chenrong'> # span=(匹配到的结果第几位开始,匹配到的长度) #有返回表示匹配到了,没返回表
shelve,xml,configparser,hashlib
shutil文件拷贝,zip,tar
random模块 import random print(random.random()) #取0-1之间的浮点值 print(random.randint(0,9)) #取0-9的随机整数 print(random.randrange(1,10)) #range 1-9随机取一个数 包含1不包含9 print(random.choice((1,2,3,4))) #choice(字符串或列表元组)
#Author:lei #时间的3种表现形式 1.时间戳 2.格式化的时间字符串 3.元组 struc_time 9个元素 #夏令时 比标准时间提前1小时 import time ''' print(time.time()) #获取时间戳 x=time.time() #当前时间与unix诞生年的时间差 print(x/3600/24/365)&nbs
mokuai.py1.定义 #模块:用来从逻辑上组织python代码(变量,函数,类,逻辑:实现一个功能).本质就是.py结尾的python文件 #文件名:test.py,对应的模块名:test 包:用来从逻辑上组织模块的,本质就是一个目录(必须带有一个__init__.py文件) 2.导入方法 #import module_name,module2_name 导入多个模块 #from
Copyright © 2005-2024 51CTO.COM 版权所有 京ICP证060544号