Python如何获取脚本的参数 [root@db01 ~]# vim 1.py #!/usr/bin/env python3 import sys script_name = sys.argv[0] p1 = sys.argv[1] p2 = sys.argv[2] p3 = sys.argv[3] print(script_name, p1, p2, p3) print(sys.argv) [root@db01 ~]# python3 1.py love mysql 3306 1.py love mysql 3306 ['1.py', 'love', 'mysql', '3306']