当前位置:网站首页>sys.argv
sys.argv
2022-07-06 08:19:00 【不求大富大贵只求富可敌国】
sys.argv可以从命令行获取参数,执行脚本。
import os
import sys
root=os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(root)
print("sys_test.argv: ",sys.argv)
print("sys_test.argv[0]: ",sys.argv[0])
print("sys_test.argv[1]: ",sys.argv[1])
print("sys_test.argv[2]: ",sys.argv[2])
print(len(sys.argv))
控制台输出:
C:\Users\jam96\PycharmProjects\all_module\sys_test>python a.py q w e r
sys_test.argv: ['a.py', 'q', 'w', 'e', 'r']
sys_test.argv[0]: a.py
sys_test.argv[1]: q
sys_test.argv[2]: w
5
1. 从python后面的.py文件计数
2. 从0开始计数
边栏推荐
- The resources of underground pipe holes are tight, and the air blowing micro cable is not fragrant?
- The Vice Minister of the Ministry of industry and information technology of "APEC industry +" of the national economic and information technology center led a team to Sichuan to investigate the operat
- [cloud native] teach you how to build ferry open source work order system
- Data governance: Data Governance under microservice architecture
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- Upgrade tidb operator
- 2.10transfrom attribute
- 指针和数组笔试题解析
- Nft智能合约发行,盲盒,公开发售技术实战--合约篇
- Wincc7.5 download and installation tutorial (win10 system)
猜你喜欢

Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center

Asia Pacific Financial Media | art cube of "designer universe": Guangzhou community designers achieve "great improvement" in urban quality | observation of stable strategy industry fund

The resources of underground pipe holes are tight, and the air blowing micro cable is not fragrant?
![08- [istio] istio gateway, virtual service and the relationship between them](/img/fb/09793f5fd12c2906b73cc42722165f.jpg)
08- [istio] istio gateway, virtual service and the relationship between them

Personalized online cloud database hybrid optimization system | SIGMOD 2022 selected papers interpretation

Asia Pacific Financial Media | female pattern ladyvision: forced the hotel to upgrade security. The drunk woman died in the guest room, and the hotel was sentenced not to pay compensation | APEC secur

在 uniapp 中使用阿里图标

指针和数组笔试题解析

wincc7.5下载安装教程(Win10系统)

Make learning pointer easier (3)
随机推荐
[Yugong series] February 2022 U3D full stack class 011 unity section 1 mind map
Grayscale upgrade tidb operator
Upgrade tidb with tiup
flask返回文件下载
[research materials] 2022 China yuancosmos white paper - Download attached
Nacos Development Manual
The Vice Minister of the Ministry of industry and information technology of "APEC industry +" of the national economic and information technology center led a team to Sichuan to investigate the operat
Summary of phased use of sonic one-stop open source distributed cluster cloud real machine test platform
Vocabulary notes for postgraduate entrance examination (3)
【MySQL】数据库的存储过程与存储函数通关教程(完整版)
Online yaml to CSV tool
A Closer Look at How Fine-tuning Changes BERT
化不掉的钟薛高,逃不出网红产品的生命周期
Tidb backup and recovery introduction
Circular reference of ES6 module
Pyqt5 development tips - obtain Manhattan distance between coordinates
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
图像融合--挑战、机遇与对策
"Designer universe": "benefit dimension" APEC public welfare + 2022 the latest slogan and the new platform will be launched soon | Asia Pacific Financial Media
CAD ARX gets the current viewport settings