随笔分类 - Python库
摘要:# re.search() 在一个字符串中搜索匹配正则表达式的第一个位置, 返回match对象 # re.match() 在一个字符串的开始位置起匹配正则表达式, 返回match对象 # re.findall() 搜索字符串, 以列表类型返回全部能匹配的子串 # re.split() 将一个字符串按
阅读全文
摘要:import xlwt workbook=xlwt.Workbook(encoding="utf-8",style_compression=0) #创建workbook对象,style_compression表示是否压缩,不常用 worksheet=workbook.add_sheet('sheet
阅读全文
摘要:import os os.makedirs('dirname1/dirname2') 可生成多层递归目录 os.removedirs('dirname1') 若目录为空,则删除,并递归到上一级目录,如若也为空,则删除,依此类推 os.mkdir('dirname') 生成单级目录;相当于shell中
阅读全文
摘要:urllib:http请求库 # urllib, python内置的一个http请求库,不需要额外的安装。只需要关注请求的链接,参数,提供了强大的解析。 import urllib urllb.request #请求模块 urllib.error #异常处理模块 urllib.parse #解析模块
阅读全文
摘要:import random print( random.randint(1,10) ) # 产生 1 到 10 的一个整数型随机数 print( random.random() ) # 产生 0 到 1 之间的随机浮点数 print( random.uniform(1.1,5.4) ) # 产生 1
阅读全文
摘要:import datetime nowtime=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') print(nowtime)
阅读全文
摘要:函数 说明 re.search() 在一个字符串中搜索匹配正则表达式的第一个位置,返回match对象 re.match() 从一个字符串的开始位置起匹配正则表达式,返回match对象 re.findall() 搜索字符串,以列表类型返回全部能匹配的子串 re.split() 将一个字符串按照正则表达
阅读全文

浙公网安备 33010602011771号