源自:2-2 python文件操作之文件读取方式
想写个python脚本实现 输入的文件名,查文件有多少行 ,不知道哪里错了。。
#!/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
aaa=input()
File "", line 1
1.txt
^
SyntaxError: unexpected EOF while parsing
[root@host36 ~]#
提问者:小木mu
2016-02-20 20:39