6

【笔记】Python获取命令行参数

 1 year ago
source link: https://en.loli.fj.cn/2022/11/26/Python%E8%8E%B7%E5%8F%96%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%8F%82%E6%95%B0/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

【笔记】Python获取命令行参数

2022-11-26

Python获取命令行参数

获取命令行参数

  • 得到的是一个数字,包含了所有的命令行参数
  • 其中第一个参数也就是sys.argv[0],其实是Python脚本名,从sys.argv[1]之后的列表元素才是传递的命令行参数
import sys

print(sys.argv[0])

菜鸟笔记


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK