摘要:
import requests res=requests.get('https://www.baidu.com/') res.raise_for_status() playFile = open('demo.txt','wb') for chunk in res.iter_counter(10000 阅读全文
摘要:
open()是python的内置函数,它会返回一个文件对象,这个文件对象拥有read、readline、write、close等方法。 语法:open('file','mode') 参数说明:file:需要打开的文件路径 mode(可选):打开文件的模式,如只读("r")、追加("a")、写入("w 阅读全文
摘要:
import os os.path.join('C:\\Users\\asweigart', filename) os.getcwd() # 获取当前目录 os.chdir(‘dirname’) # 改变当前目录 os.path.exits() # 文件或文件夹是否存在 os.path.isdir( 阅读全文
摘要:
form urllib import request jpg_link = '......' #图片链接 request.urlretrieve(jpg_link, path) # path为路径,如果不需要路径,也要有个名字,如 111.jpg就直接保存在当前目录下 阅读全文
摘要:
字符串str,二进制字符bytes。Python 3不会以任意隐式的方式混用str和bytes,你不能拼接字符串和字节流,也无法在字节流里搜索字符串。 内置函数bytes()可以将字符串str类型转换成bytes类型,如:b = bytes(s, encoding='utf-8') 内置函数str( 阅读全文
摘要:
读 from openpyxl import load_workbook excel = load_workbook('E:/test.xlsx') # 打开文件 sheet = excel["Sheet1"] # 获取表名 rows=sheet.max_row # 获取行数 cols=sheet. 阅读全文