1. Import Module:
Import osfrom OS import systemimport socketserver as SS --alias 2, use the TAB key: [[email protected] python]# cat tab.py#py Thon Startup FileImport sysimport readlineimport rlcompleterimport os#tab completionreadline.parse_and_bind (' tab: Complete ') #history Filehistfile = Os.path.join (os.environ[' HOME '), '. Pythonhistory ') #try: # Readline.read_history_file (histfile) #except ioerror:# PASS3, formatted output: #!/usr/bin/env Pythonthis_ Year=2015name=raw_input (' What's Your Name: ') age=int (raw_input. ') sex=raw_input (' How old is you? Dep=raw_input (' How old is? ') ') messages = ' Information of the company staff: name:%s Age:%S&N Bsp Gender:%s DEP:%s '% (NAME,AGE,SEX,DEP) prin T messages 4, normalized output: 1 #!/usr/bin/env python 2 import sys 3 user = ' Cheeron ' 4 TIMES=0&N Bsp 5 while True: 6 If times<3: 7 name = Raw_input (' What's Your Name: '). Strip () 8 If len (name) = = 0: 9 print ' name is not empty,please input a name ' 10 &NBSP ; continue 11 elif user = name: 12 pass 13 &N Bsp else: 14 print "%s is not right,please sign in agin!"% name 15 times+=1 16 continue 17 break 18 else: 19 &NB Sp Sys.exit () 20 age = Int (raw_input ') 21 sex = raw_input (' Please input your gender: ') 22 dep = raw_input (' Please input your job: ') 23 print "Welcome to sign in", Name 1 #!/usr/bin/env python 2 Import sys 3 user = ' Cheeron ' 4 times=0& nbsp 5 while true: 6 name = Raw_inputR name: '). Strip () 7 If len (name) = = 0: 8 print ' name is not empty,p Lease input a name ' 9 CONTINUE&NBSP;10 for I in range (3): 11 & nbsp name = Raw_input (' What's Your Name: '). Strip () 12 if user = = Name: 13 pass 14 else: 15 &NB Sp Print "%s is not right,please sign in agin!"% name 16 Contin ue 17 break 18 else: 19 print "has lo Gin 3 Times,exit " 20 sys.exit () 21 break 22 age = Int (Raw_input (' How is old is you? ') 23 sex = raw_input (' Please input your gender: ') 24 dep = raw_input (' Please input your job: ') 25 PRint "Welcome to sign in", name
Python Learning Path---programming style specification