代码:import os;
o=open("i:\pycode\mylog.txt");
content=o.read(16);print content;
o.close();if os.path.exists("i:\pycode\mylog.txt"): os.remove("i:\pycode\mylog.txt"); print "The file have been deleted!";出错结果:Traceback (most recent call last):
File "I:\pycode\PythonApplication1\PythonApplication1\osfile.py", line 7, in <module>
os.remove("i:\pycode\mylog.txt");
WindowsError: [Error 32] : 'i:\\pycode\\mylog.txt'>>>
1 回答
小唯快跑啊
TA贡献1863条经验 获得超2个赞
试试把\转换为\\
import os; o=open("i:\\pycode\\mylog.txt"); content=o.read(16);print content; o.close();if os.path.exists("i:\\pycode\\mylog.txt"): os.remove("i:\\pycode\\mylog.txt"); print "The file have been deleted!";
添加回答
举报
0/150
提交
取消