【问题标题】:The letter 'n' is invalid syntax in Python? [closed]Python中的字母'n'是无效的语法? [关闭]
【发布时间】:2013-05-03 05:26:10
【问题描述】:

它之前在我的程序中作为变量名工作,现在突然之间,Python 在我的程序中一直将字母“n”作为无效语法返回。

知道为什么,以及如何解决这个问题吗?

bad_input=True
while bad_input:
    bad_input=False
    User_Choice=int(input('Which frame would you like to choose(1,2,3 represent positive selections, 4,5,6 represent -1,-2, and -3 respectively')
    n = 3
    if User_Choice== int(1):
        Chunks=[RNA_Comp[i:i+n] for i in range(0, len(RNA_Comp), n)]
    if User_Choice== int(2):
        Chunks=[RNA_Comp[i:i+n] for i in range(1, len(RNA_Comp), n)]
    if User_Choice== int(3):
        Chunks=[RNA_Comp[i:i+n] for i in range(2, len(RNA_Comp), n)]
    else:
        print('Please select an integer value from 1 to 6')
        bad_input=True

【问题讨论】:

  • 注解即可,int(1)int(2)等不用做,直接用号码代替即可。
  • 投了反对票,因为这只是一个简单的语法错误——不太可能帮助其他人。

标签: python variables syntax


【解决方案1】:

您忘记在n = 3 之前的行中关闭)

【讨论】:

  • 你的意思是在上面,而不是在下面
  • 是的,我知道,在我看到你的评论之前更正它:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-02
  • 2023-03-04
  • 2022-08-24
相关资源
最近更新 更多