python3中文件操作及编码

#之前一直没明白文件处理中的w和wb的区别到底是什么,
#在看过视频后才知道,原来在linux里面是没有区别的,
#但是在windows里面就能够看出区别来了
#下面来个例子:

with open("普通文本文件.txt", "w",encoding='utf-8') as f:
data = 'This is testing! This is testing!'
f.write(data)
f.close()

with open("二进制文本文件.txt", "wb") as f:
data = b'This is testing! This is testing!'
f.write(data)
f.close()

原文地址:https://www.cnblogs.com/walo/p/10587809.html