SYS.ARGV is the command line parameter;
Sys.argv[0] Represents the file path of the code itself; Gets the parameters starting from 1.
Import Sys
Print (Sys.argv[0])
count = Int (sys.argv[1])
Devicelist = Deviceparser (). Getdevicelist ()
If Devicelist is not None and devicelist.__len__ () > 0:
Target_device = devicelist[0]
Device_serial = Target_device.devicename
Pkg_name = str (sys.argv[2])
Interval_c = Int (sys.argv[3])
Log_dir = str (sys.argv[4])
Introducing SYS
SYS.ARGV[0] The path to the code itself D:\cpu\device_system_info2.py
SYS.ARGV[1] Get parameters and convert to int type 200
Pkg_name = str (sys.argv[2]) package name
Interval_c = Int (sys.argv[3]) 3 times
Log_dir = str (sys.argv[4]) D:\cpuinfoReport
Execute d at the command line:
CD D:\CPU
Python D:\cpu\device_system_info2.py 200 Package name 3 D:\cpuinfoReport
Tune up the Python program.
Python Learning--sys.argv