Python COMMAND LINE PROCESSING

Source: Internet
Author: User

Python COMMAND LINE PROCESSING

 #  Coding = UTF-8  '''  Lovely Python-3 pyday pycdc v0.3 @ see: http: ## www.woodpecker.org.cn?dive=python=scripts_and_streams=command_line_arguments.html  '''  Import  OS, sys  Import Getopt #  Import the getopt Module CDROM = '  # Media # cdrom0  ' Def  Cdwalker (CDROM, cdcfile): Export = ""      For Root, dirs, files In  OS. Walk (CDROM): Export + = "  \ N % s; % s  " % (Root, dirs, files) #  # The + = here does not actually use the join Method for High Efficiency Open (cdcfile, '  W  ' ). Write (Export) #  # Add 'w' to open and create a new one  Def  Usage ():  Print   '''  Pycdc usage: Python cdays-3-exercise-1.py-d cdc-K China fire # search for CD information in the CDC directory, find a file or directory with the words "China Fire", in which disk  '''  Try  : Opts, argS = Getopt. getopt (SYS. argv [1:], '  HD: e: K:  ' )#  # Do not add after H: because there are no other parameters  Except  Getopt. getopterror: usage () SYS. Exit ()  If Len (OPTs) = 0: usage () SYS. Exit () c_path = ''  For Opt, ARG In Opts: #  # Arg is read from this opts and does not understand the usefulness of The args above     If OPT In ( ' -H  ' , '  -- Help  '  ): Usage () SYS. Exit ()  Elif Opt = '  -E  '  :  #  Identifies whether SYS. argv [2] has a directory for automatic creation.             #  Cdwalker (CDROM, ARG)        Print  "  Record the disc information to % s  " % ARG  Elif Opt = '  -D  '  : C_path = ARG  Elif Opt = '  -K  '  :  If  Not C_path: #  # The following command is run when c_path is '', that is, it is not assigned a value.  Usage () SYS. Exit ()  #  Search for files 

 

End

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.