First write a little put up, not complete, Monday to the company in the optimization bar.
Here the user input is written to the file, using variables, this variable was studied overnight.
F.write ('%s \ n% variable ') also unexpected variables are written outside ().
Localhost:python dong$ cat denglu.py #!/usr/bin/env pythonf = open ('/Users/ Dong/documents/java/python/zh ', ' W ') Logou_flag = falsefor i in range (3): user_input=raw_input (' please,user: '). Strip () if len (user_input) == 0: print ' Error:you must input sth as name. ' continue else: f.write ('%s\n ' % user_input) password=raw_input (" please,password : "). Strip () if len (PASSWORD) == 0: print ' Error:you must input sth as password ' continue else: f.write ('%s\n ' % password ) f.flush f.close print ' Success! '
Localhost:python dong$ cat en
1
1
2
2
3
3
This article from the "Clear Sky" blog, declined reprint!
Python First day job