所以从你的评论来看,我认为你希望:
def method1(arg):
print("hello", arg)
def method2(arg):
print("Whatsup", arg)
if __name__ == "__main__":
import sys
#print(sys.argv)
func = sys.argv[1]
arg = sys.argv[2]
if func == "method1": method1(arg)
elif func == "method2": method2(arg)
现在运行这个
python3 hello.py method1 John
这是一个肮脏的例子,如果你想要更多的选择,你需要调整很多。