当前位置:网站首页>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开始计数
边栏推荐
- Circuit breaker: use of hystrix
- leetcode刷题 (5.31) 字符串
- Hungry for 4 years + Ali for 2 years: some conclusions and Thoughts on the road of research and development
- Restore backup data on S3 compatible storage with tidb lightning
- Mobile Test Engineer occupation yyds dry goods inventory
- C语言 - 位段
- Zhong Xuegao, who cannot be melted, cannot escape the life cycle of online celebrity products
- 2. File operation - write
- NFT smart contract release, blind box, public offering technology practice -- jigsaw puzzle
- MFC 给列表控件发送左键单击、双击、以及右键单击消息
猜你喜欢

Leetcode question brushing record | 203_ Remove linked list elements

Zhong Xuegao, who cannot be melted, cannot escape the life cycle of online celebrity products

Nft智能合约发行,盲盒,公开发售技术实战--合约篇

将 NFT 设置为 ENS 个人资料头像的分步指南
![[research materials] 2022 enterprise wechat Ecosystem Research Report - Download attached](/img/35/898a8086bc35462b0fcb9e6b58b86b.jpg)
[research materials] 2022 enterprise wechat Ecosystem Research Report - Download attached

Hcip day 16

化不掉的钟薛高,逃不出网红产品的生命周期
![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

IoT -- 解读物联网四层架构

Secure captcha (unsafe verification code) of DVWA range
随机推荐
VMware 虚拟化集群
IP lab, the first weekly recheck
"Friendship and righteousness" of the center for national economy and information technology: China's friendship wine - the "unparalleled loyalty and righteousness" of the solidarity group released th
Erc20 token agreement
Zhong Xuegao, who cannot be melted, cannot escape the life cycle of online celebrity products
[research materials] 2022 enterprise wechat Ecosystem Research Report - Download attached
21. Delete data
Uibehavior, a comprehensive exploration of ugui source code
使用 TiDB Lightning 恢复 S3 兼容存储上的备份数据
Epoll and IO multiplexing of redis
Restore backup data on S3 compatible storage with br
从 SQL 文件迁移数据到 TiDB
1202 character lookup
让学指针变得更简单(三)
matplotlib. Widgets are easy to use
[research materials] 2021 China online high growth white paper - Download attached
"Designer universe" Guangdong responds to the opinions of the national development and Reform Commission. Primary school students incarnate as small community designers | national economic and Informa
Easy to use tcp-udp_ Debug tool download and use
C language custom type: struct
A Closer Look at How Fine-tuning Changes BERT