当前位置:网站首页>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开始计数
边栏推荐
- Sanzi chess (C language)
- 远程存储访问授权
- Common functions for PHP to process strings
- Online yaml to CSV tool
- 指针进阶---指针数组,数组指针
- Data governance: misunderstanding sorting
- 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
- ESP系列引脚說明圖匯總
- Circular reference of ES6 module
- Migrate data from SQL files to tidb
猜你喜欢

C language custom type: struct

好用的TCP-UDP_debug工具下载和使用

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

Chinese Remainder Theorem (Sun Tzu theorem) principle and template code

"Designer universe": "benefit dimension" APEC public welfare + 2022 the latest slogan and the new platform will be launched soon | Asia Pacific Financial Media

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

"Designer universe" APEC design +: the list of winners of the Paris Design Award in France was recently announced. The winners of "Changsha world center Damei mansion" were awarded by the national eco
![[research materials] 2021 China online high growth white paper - Download attached](/img/51/bea6179e4fac88f8b550b4213a2bca.jpg)
[research materials] 2021 China online high growth white paper - Download attached

Go learning notes (3) basic types and statements (2)

IP lab, the first weekly recheck
随机推荐
ESP系列引脚說明圖匯總
logback1.3. X configuration details and Practice
使用 Dumpling 备份 TiDB 集群数据到兼容 S3 的存储
"Designer universe": "benefit dimension" APEC public welfare + 2022 the latest slogan and the new platform will be launched soon | Asia Pacific Financial Media
leetcode刷题 (5.29) 哈希表
Data governance: misunderstanding sorting
1204 character deletion operation (2)
使用 TiDB Lightning 恢复 S3 兼容存储上的备份数据
Hcip day 16
Analysis of pointer and array written test questions
wincc7.5下载安装教程(Win10系统)
leetcode刷题 (5.31) 字符串
Online yaml to CSV tool
2. File operation - write
PHP - Common magic method (nanny level teaching)
24. Query table data (basic)
22. Empty the table
What is the use of entering the critical point? How to realize STM32 single chip microcomputer?
[Yugong series] creation of 009 unity object of U3D full stack class in February 2022
Circuit breaker: use of hystrix