简体   繁体   English

注释部分出现缩进错误:Python

[英]Indentation error in comment section: Python

I'm receiving the msg: "unexpected indent (, line 2) pylint(syntax-error) [Ln 2, Col 3]" every time I try to run the code below.每次我尝试运行下面的代码时,我都会收到消息:“unexpected indent (, line 2) pylint(syntax-error) [Ln 2, Col 3]”。 Indent shouldn't matter in commented out sections, right?在注释掉的部分中缩进不重要,对吧? But whenever I try deleting the commented section and run the code again it gives me the same message.但是,每当我尝试删除注释部分并再次运行代码时,它都会给我同样的信息。 At a loss.不知所措。 How do I fix this?我该如何解决?

CODE:代码:

"""
  Students  |  Grades  |  Letters
------------|----------|----------
  George    |  46      |  F
  Michell   |  80      |  B
  Josh      |  12      |  F
  Chloe     |  68      |  D
  Stanley   |  99      |  A
  Annie     |  100     |  A+
"""

gradeToTest = 0
if gradeToTest == 100:
    print("A+")
elif gradeToTest >= 90:
    print("A")
elif gradeToTest >= 80:
    print("B")
elif gradeToTest >= 70:
    print("C")
elif gradeToTest >= 50:
    print("D")
else:
    print("F")

try this maybe?试试这个也许?

  if gradeToTest == '100' :
    print("A+")
elif gradeToTest >= '90' :
    print("A")
elif gradeToTest >= '80' :
    print("B")
elif gradeToTest >= '70' :
    print("C")
elif gradeToTest >= '50' :
    print("D")
else:
    print("F")

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

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