from sys import argv
# 解包
script, one, two, three = argv
print("script: ",script)
print("1: ",one)
print("2: ",two)
print("3: ",three)
文件保存为ex13.py
配置入参:
结果为:
* import
语句,是将python的特性引入脚本的方法
* argv
即所谓的变量参数
*
将argv解包给4个变量,script是程序的全路径+执行文件名
*
模块(特性的另一个名字),将这些导入的特性称为模块
* argv
用户执行命令时输入,input() 脚本运行过程中需要时输入
*
命令行参数都是字符串,若想变为数字,像int(input())这样写