类型错误:“列表”对象不可调用,sys.argv()

时间:2020-12-20 15:19:51

标签: python list typeerror

我正在编写一个在终端中运行的 Python 脚本,用于对消息进行编码和解码。我正在使用 sys.argv() 来检查用户是否想要对其进行编码或解码,但它说“列表”对象不可调用?

    #encode or decode
    enorde = 0
    for arg in sys.argv(): #error here
        if enorde == 0:
            if arg == 'encode':
                encode()
            elif arg == 'decode':
                decode()
            else:
                print("Unknown argument: ",arg)
            enorde = enorde + 1
        else:
            break 

和终端:

  File "./secmsg.py", line 117, in <module>
    startup()
  File "./secmsg.py", line 38, in startup
    for arg in sys.argv():
TypeError: 'list' object is not callable

有什么原因吗?

1 个答案:

答案 0 :(得分:0)

抱歉,完全没有意识到 sys.argv 没有使用括号!

相关问题