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)
     

  • 相关阅读:
    php学习day12---数据库(4)数据表的连接查询,子查询和联合查询
    php学习day11---数据库(3)数据表的增删改查
    php学习day10---数据库基础2
    php学习day9---数据库的基本知识
    php学习day8---数组的知识
    php学习day7--函数的相关知识
    资源相互引用时 需添加 PerformSubstitution=True
    C++完美实现Singleton模式[转]
    shell
    AJAX enabled & disabled
  • 原文地址:https://www.cnblogs.com/jiangnanmu/p/5491791.html
Copyright © 2011-2022 走看看