|
在学习到file时,写了个例子如下,但是运行报错,求帮忙解答如何修改?
# 打开一个文件
fo = open("foo1.txt", "wb")
fo.write("abc");
# 关闭打开的文件
fo.close()
------------------------
C:\Users\Administrator\AppData\Local\Programs\Python\Python36\python.exe D:/study/study/TEST/PythonTest/test.py
Traceback (most recent call last):
File "D:/study/study/TEST/PythonTest/test.py", line 8, in <module>
fo.write("abc");
TypeError: a bytes-like object is required, not 'str'
Process finished with exit code 1
|
|