1. ホーム

Python Basics: io.UnsupportedOperation: 読み取れません。

2022-02-08 02:14:02
fo = open("F:/a.txt","w")
print("filename",fo.name)
print("is it closed:",fo.closed)
print("mode:",fo.mode)

fo.write("aaaaaa\n")
fo.close()


'''Here you have to close before you can read, and you have to change to read-only mode'''
fo = open("F:/a.txt","r")
re = fo.read()
print("The content read is",re)
fo.close()