小木mu
2016-02-20 20:39
#!/usr/bin/python
aaa=input()
print("the file is ", aaa)
f = open('aaa')
iter_f = iter(f)
lines=0
for line in iter_f:
lines += 1
print("is", lines)
运行结果报错: [root@host36 ~]# python test.py 1.txt Traceback (most recent call last): File "test.py", line 2, in <module> aaa=input() File "<string>", line 1 1.txt ^ SyntaxError: unexpected EOF while parsing [root@host36 ~]#
把 input 改为 raw_input ,python 3 需要 eval() 函数修饰一下 ?
http://stackoverflow.com/questions/21122540/python-input-error-nameerror-name-is-not-defined
Python文件处理
88454 学习 · 107 问题
相似问题