Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道优秀的程序员如何在 Python 中获取命令行参数?如果有很多参数怎么办?
def main(): type = None if len(sys.argv) == 1 else sys.argv[1] date = None if len(sys.argv) != 3 else sys.argv[2]
查看argparse,它正在替换 optparse。