当前位置:网站首页>sys. argv

sys. argv

2022-07-06 08:24:00 Don't seek great wealth, just seek wealth to rival the country

sys.argv Parameters can be obtained from the command line , Execute the script .

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))

Console output :

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. from python hinder .py File count
2. from 0 Start counting

原网站

版权声明
本文为[Don't seek great wealth, just seek wealth to rival the country]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060819357438.html