with open('Label.js', 'wb') as f:
f.write("var")
报错
TypeError: a bytes-like object is required, not ‘str’ when writing to a file in Python3
这是由于以binary打开文件
解决方法
with open('Label.js', 'w') as f:
f.write("var")
with open('Label.js', 'wb') as f:
f.write("var")
报错
TypeError: a bytes-like object is required, not ‘str’ when writing to a file in Python3
这是由于以binary打开文件
解决方法
with open('Label.js', 'w') as f:
f.write("var")