码迷,mamicode.com
首页 > 编程语言 > 详细

Python输入和输出

时间:2017-03-09 01:39:20      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:输入与输出练习

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!‘


Python输入和输出

标签:输入与输出练习

原文地址:http://2889688.blog.51cto.com/2879688/1904360

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!