Python Learning--sys.argv

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.