with open('11.html','rw',encoding='utf-8') as f: f.write(response.text)
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
ValueError: must have exactly one of create/read/write/append mode
with open('11.html','w+',encoding='utf-8') as f: f.write(response.text)
python中的open函数没有rw这个参数,如果需要又读又写,可以使用r+或者w+来代替。
r | 默认读取 |
r+ | 读写文件 |
rb | 读二进制 |
rb+ | 读写二进制 |
w | 默认写 |
w+ | 读写文件 |
wb | 写二进制 |
wb+ | 读写二进制 |
a | 默认追加 |
a+ | 追加写入和读取 |
ab | 追加二进制 |
ab+ | 追加写入和读取二进制 |