zoukankan      html  css  js  c++  java
  • Python之路【第一篇】:Python基础(3)

    import getpass

    [root@localhost ~]# cat test_getpass.py
    import getpass
    username = input("username:")
    password = getpass.getpass("password:")
    print(username,password)
    [root@localhost ~]# python3 test_getpass.py
    username:jam 
    password:
    jam hello
    [root@localhost ~]#
     

     C:UsersJam>python2
    Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:40:30) [MSC v.1500 64 bit (
    AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import getpass
    >>> username = input("username:")
    username:jam
    Traceback (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:UsersJam>python
    Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:54:25) [MSC v.1900 64 bit (AM
    D64)] on win32
    Type "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/env python
    # -*- coding: utf-8 -*-

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

  • 相关阅读:
    婚姻中媒人存在的客观逻辑——leo鉴书45
    为什么要使用RTP
    OCP-1Z0-053-200题-148题-485
    OCP-1Z0-053-200题-149题-78
    OCP-1Z0-053-200题-150题-236
    OCP-1Z0-053-200题-151题-53
    OCP-1Z0-053-200题-152题-56
    OCP-1Z0-053-200题-153题-211
    OCP-1Z0-053-200题-154题-208
    OCP-1Z0-053-200题-155题-218
  • 原文地址:https://www.cnblogs.com/jiangnanmu/p/5491791.html
Copyright © 2011-2022 走看看