Python之路【第一篇】:Python基础(3),,import get


import getpass

[root@localhost ~]# cat test_getpass.pyimport getpassusername = input("username:")password = getpass.getpass("password:")print(username,password)[root@localhost ~]# python3 test_getpass.pyusername:jampassword:jam hello[root@localhost ~]#
C:\Users\Jam>python2Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> import getpass>>> username = input("username:")username:jamTraceback (most recent call last): File "<stdin>", line 1, in <module> File "<string>", line 1, in <module>NameError: name ‘jam‘ is not defined>>> username = raw_input("username:")username:jam>>> password = getpass.getpass("password:")password:>>> print(username,password)(‘jam‘, ‘hello123‘)>>>
C:\Users\Jam>pythonPython 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> username = input("username:")username:jam>>> password = getpass.getpass("password:")Traceback (most recent call last): File "<stdin>", line 1, in <module>NameError: name ‘getpass‘ is not defined>>> import getpass>>> username = input("username:")username:jam>>> password = getpass.getpass("password:")password:>>> print(username,password)jam hello123>>>
#!/usr/bin/envpython
#-*-coding:utf-8-*-

#pycharm里面无法使用getpass方法,在linux和windows的python上面可以正常运行
importgetpass
username=input("username:")
passwrod=getpass.getpass("password:")print(username,passwrod)

Python之路【第一篇】:Python基础(3)

相关内容

    暂无相关文章

评论关闭