问个python脚本,报错
code:spath="e:\test\test.txt"
f=open(spath,'w')
f.write("First Line1.\n")
f.writelines("Second Line2.")
f.close()
run:
Traceback (most recent call last):
File "E:\MYPYTHON\p1.py", line 7, in <module>
f=open(spath,'w')
OSError: Invalid argument: 'e:\test\test.txt' window上使用正斜杠 回复 2# HH106
改成正斜杠报错:
Traceback (most recent call last):
File "E:\MYPYTHON\p1.py", line 7, in <module>
f=open(spath,'w')
OSError: Invalid argument: 'e:\test\test.txt' 回复 3# tomer
你赢了
spath="e:\test\test.txt"===> spath="e:/test/test.txt"
回复 4# HH106
:mrgreen:
靠,明明是改过来了 回复 3# tomer
windows上是两个斜杠吧 回复 6# bulletmarquis
写成这样就可以了
spath="e:/test/test.txt" 回复 7# tomer
咦,我记得windows下os.sep是两个斜杠的呀。。。
页:
[1]