简体   繁体   English

Python意外缩进,但缩进正确

[英]Python unexpected indent ,but indent is right

Below is my code, simple routine, cannot figure out what is wrong with the indent, but keeps getting complain right after the val=line.strip().split() no matter what I put there... 下面是我的代码,简单的例程,无法找出缩进的问题,但是无论我放在哪里,都不断在val = line.strip()。split()之后抱怨。

if line.startswith('U'):
    val = line.strip().split()
    print val

This line is indented by 4 spaces 这行缩进了4个空格

val = line.strip().split()

This one is indented by a TAB 此选项卡由TAB缩进

print val

In many editors (including SO) these appear to be indented the same. 在许多编辑器(包括SO)中,它们的缩进似乎相同。 It's possible to mix tab and space indenting in Python, but a really really bad idea 可以在Python中混合使用制表符和空格缩进,但这是一个非常糟糕的主意

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM