简体   繁体   English

TypeError: 'list' object 不可调用,sys.argv()

[英]TypeError: 'list' object is not callable, sys.argv()

I'm working on a python script to run in Terminal that encodes and decodes a message.我正在开发一个 python 脚本,以在终端中运行,对消息进行编码和解码。 I'm using sys.argv() to check whether the user wants to encode it or decode it, but it's saying that 'list' object is not callable?我正在使用 sys.argv() 来检查用户是否要对其进行编码或解码,但它是说“列表” object 不可调用?

    #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 

And terminal:和终端:

  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

Any reasons?有什么理由吗?

Sorry, completely didn't realize sys.argv didn't use parentheses!对不起,完全没有意识到 sys.argv 没有使用括号!

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

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