这是做什么用的?- ArgName in ("-h", "--help") [in python]

2024-04-20 12:13:49 发布

您现在位置:Python中文网/ 问答频道 /正文

有人能解释一下这是什么意思吗?请用一些简单的术语,随便一个在街上的人都能理解。谢谢


Tags: 术语
1条回答
网友
1楼 · 发布于 2024-04-20 12:13:49

试着在你的控制台里测试这些东西。。。它们是不言自明的。你知道吗

# set a value for ArgName 
>>> ArgName = "-h"
# see if that value is in this tuple
>>> ArgName in ("-h"," help")
True # because ArgName = '-h' which is in the tuple
>>> ArgName = " help"
>>> ArgName in ("-h"," help")
True # because ArgName = ' help' which is in the tuple
>>> ArgName = "something"
>>> ArgName in ("-h"," help")
False # because ArgName = 'something' which is NOT in the tuple

相关问题 更多 >