我正在运行python代码,代码是:
f = open("File.txt", "r")
f.write("my first file\n")
f.write("my second file \n\n")
f.write("contains three lines\n")
f.read(2)但我一直有个错误:
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS F:\ping> python -u "f:\ping\file.py"
Traceback (most recent call last): File "f:\ping\file.py", line 2, in <module>
f.write("my first file\n")
io.UnsupportedOperation: not writable我的密码怎么了?
发布于 2022-04-24 12:42:10
以读取模式打开文件。将"r"更改为"w"。
f = open("File.txt", "w")https://stackoverflow.com/questions/71988517
复制相似问题