您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息
三六零分类信息网 > 邯郸分类信息网,免费分类信息发布

详解Python输入和输出

2024/12/22 8:45:19发布15次查看
这篇文章介绍详解python输入和输出
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
执行结果:
[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输入和输出的详细内容。
邯郸分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录