Python輸入和輸出

egex1.py

#!/usr/bin/env python

# _*_ coding = utf-8 _*_

 

import getpass

 

name = raw_input('please inputyour username:')

pwd = getpass.getpass('inputyour password:')

 

print 'the name is:',name

print 'the password is:',pwd

 

執行結果:

[root@localhost~]# python ex1.py

please input yourusername:huwei

input yourpassword:

the name is:huwei

the password is:huwei123

 

eg:修改的ex1.py

#!/usr/bin/env python

# _*_ coding = utf-8 _*_

 

import getpass

 

name = raw_input('please inputyour username:')

pwd = getpass.getpass('inputyour password:')

 

print 'the name is:',name

print 'the password is:',pwd

 

if name == 'huwei' and pwd =='huwei123':

 print 'you login successfully!'

 

執行結果:

[root@localhost~]# python ex1.py

please input yourusername:huwei

input yourpassword:

the name is:huwei

the password is:huwei1234

[root@localhost~]# python ex1.py

please input yourusername:huwei

input yourpassword:

the name is:huwei

the password is:huwei123

you loginsuccessfully!

 

eg:修改ex1.py

#!/usr/bin/env python

# _*_ coding = utf-8 _*_

 

import getpass

 

name = raw_input('please inputyour username:')

pwd = getpass.getpass('inputyour password:')

 

print 'the name is:',name

print 'the password is:',pwd

 

if name == 'huwei' and pwd =='huwei123':

 print 'you login successfully!'

else:

 print 'your password is wrong!'

 

 

執行結果:

#!/usr/bin/envpython

# _*_ coding =utf-8 _*_

 

import getpass

 

name =raw_input('please input your username:')

pwd =getpass.getpass('input your password:')

 

print 'the nameis:',name

print 'thepassword is:',pwd

 

if name =='huwei' and pwd == 'huwei123':

 print 'you login successfully!'


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章