sti*_*ihl -6 python syntax loops for-loop
为什么这不会编译......我很难过......
for files in glob.glob("*.txt"):
f=open(files)
for lines in f:
print lines
Run Code Online (Sandbox Code Playgroud)
我明白了:
File "teleparse.py", line 21
for lines in f:
^
IndentationError: unexpected indent
Run Code Online (Sandbox Code Playgroud)
"不,我确保缩进只包含标签."
你错了:
>>> s = """
...
... for files in glob.glob("*.txt"):
... f=open(files)
... for lines in f:
... print lines
... """
>>>
>>> for line in s.splitlines():
... print repr(line)
...
''
''
' for files in glob.glob("*.txt"):'
' f=open(files)'
'\t for lines in f:'
'\t\t print lines'
Run Code Online (Sandbox Code Playgroud)
您可以python -tt yourprogramname.py用来确认您正在混合制表符和空格.