Python cmd module exercises

Source: Internet
Author: User

1 #Encoding=utf-82 Importcmd3 ImportSYS4 5 6 #cmd module Exercises7 8 classClient (cmd. CMD):9 Ten     " " One 1) cmdloop (): Similar to the Tkinter Mainloop, run the CMD parser; A 2) Onecmd (str): read input, and processing, usually do not need to overload the function, but use more specific do_command to perform a specific naming; - 3) Emptyline (): This method is called when an empty row is entered; - 4) Default (line): This method is called when an input command is not recognized; the 5) Completedefault (TEXT,LINE,BEGIDX,ENDIDX): If there is no complete_* () method on it, the function is called - 6) Precmd (line): command line parsing before the method is called; - 7) Postcmd (stop,line): command line is called after parsing the method; - 8) Preloop (): Cmdloop () call the method before running; + 9) Postloop (): Cmdloop () call the method after exiting; -  +     " " A  at     def __init__(self): -Cmd.cmd.__init__(self) -Self.prompt ='>' -  -     defDo_hello (Self, arg): -         Print "Hello again", ARG,"!" in  -     defHelp_hello (self): to         Print "Syntax:hello [message]", +         Print "--Prints a Hello message" -  the     defdo_quit (Self, arg): *Sys.exit (1) $ Panax Notoginseng     defHelp_quit (self): -         Print "Syntax:quit", the         Print "--Terminates the application" +         #Shortcuts ADo_q =Do_quit theDo_eof =Do_quit +  - if __name__=='__main__': $Client =Client () $Client.cmdloop ()#Cmdloop (): Similar to the Tkinter Mainloop, run the CMD parser;

Python cmd module exercises

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.