📄 module-getpass.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>6.11 getpass -- Portable password input</title>
<META NAME="description" CONTENT="6.11 getpass -- Portable password input">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="STYLESHEET" href="lib.css" tppabs="http://www.python.org/doc/current/lib/lib.css">
<LINK REL="next" href="module-curses.html" tppabs="http://www.python.org/doc/current/lib/module-curses.html">
<LINK REL="previous" href="module-sched.html" tppabs="http://www.python.org/doc/current/lib/module-sched.html">
<LINK REL="up" href="allos.html" tppabs="http://www.python.org/doc/current/lib/allos.html">
<LINK REL="next" href="module-curses.html" tppabs="http://www.python.org/doc/current/lib/module-curses.html">
</head>
<body>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="scheduler-objects.html" tppabs="http://www.python.org/doc/current/lib/scheduler-objects.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="allos.html" tppabs="http://www.python.org/doc/current/lib/allos.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="module-curses.html" tppabs="http://www.python.org/doc/current/lib/module-curses.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="scheduler-objects.html" tppabs="http://www.python.org/doc/current/lib/scheduler-objects.html">6.10.1 Scheduler Objects</A>
<b class="navlabel">Up:</b> <a class="sectref" href="allos.html" tppabs="http://www.python.org/doc/current/lib/allos.html">6. Generic Operating System</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-curses.html" tppabs="http://www.python.org/doc/current/lib/module-curses.html">6.12 curses </A>
<br><hr></DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION0081100000000000000000">
6.11 <tt class="module">getpass</tt>
-- Portable password input</A>
</H1>
<P>
<P>
The <tt class="module">getpass</tt> module provides two functions:
<P>
<dl><dt><b><a name='l2h-1166'><tt class='function'>getpass</tt></a></b> (<big>[</big><var>prompt</var><big>]</big>)
<dd>
Prompt the user for a password without echoing. The user is
prompted using the string <var>prompt</var>, which defaults to
<code>'Password: '</code>.
Availability: Macintosh, Unix, Windows.
</dl>
<P>
<dl><dt><b><a name='l2h-1167'><tt class='function'>getuser</tt></a></b> ()
<dd>
Return the ``login name'' of the user.
Availability: Unix, Windows.
<P>
This function checks the environment variables <a class="envvar" name='l2h-1168'>$LOGNAME</a>,
<a class="envvar" name='l2h-1169'>$USER</a>, <a class="envvar" name='l2h-1170'>$LNAME</a> and <a class="envvar" name='l2h-1171'>$USERNAME</a>, in order, and
returns the value of the first one which is set to a non-empty
string. If none are set, the login name from the password database
is returned on systems which support the <tt class='module'><a href="module-pwd.html" tppabs="http://www.python.org/doc/current/lib/module-pwd.html">pwd</a></tt> module,
otherwise, an exception is raised.
</dl>
<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="scheduler-objects.html" tppabs="http://www.python.org/doc/current/lib/scheduler-objects.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="allos.html" tppabs="http://www.python.org/doc/current/lib/allos.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="module-curses.html" tppabs="http://www.python.org/doc/current/lib/module-curses.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="scheduler-objects.html" tppabs="http://www.python.org/doc/current/lib/scheduler-objects.html">6.10.1 Scheduler Objects</A>
<b class="navlabel">Up:</b> <a class="sectref" href="allos.html" tppabs="http://www.python.org/doc/current/lib/allos.html">6. Generic Operating System</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-curses.html" tppabs="http://www.python.org/doc/current/lib/module-curses.html">6.12 curses </A>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>See <i><a href="about.html" tppabs="http://www.python.org/doc/current/lib/about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -