Maison > développement back-end > Tutoriel Python > sinon, processus de jugement-CLASS-11 (Partie 1)

sinon, processus de jugement-CLASS-11 (Partie 1)

PHP中文网
Libérer: 2017-07-04 19:30:03
original
1266 Les gens l'ont consulté

si déclaration de jugement

<span style="color: #008080">1</span> <span style="color: #0000ff">if</span><span style="color: #000000"> true:
</span><span style="color: #008080">2</span>     <span style="color: #0000ff">print</span>(<span style="color: #800000">"</span><span style="color: #800000">true</span><span style="color: #800000">"</span><span style="color: #000000">)
</span><span style="color: #008080">3</span> <span style="color: #0000ff">else</span><span style="color: #000000">:
</span><span style="color: #008080">4</span>     <span style="color: #0000ff">print</span>(<span style="color: #800000">"</span><span style="color: #800000">false</span><span style="color: #800000">"</span>)
Copier après la connexion

Devinez votre âge

<span style="color: #008080">1</span> <span style="color: #008000">#</span><span style="color: #008000"> Author:dd</span>
<span style="color: #008080">2</span> age_of_boy = 56
<span style="color: #008080">3</span> age = int(input(<span style="color: #800000">"</span><span style="color: #800000">age:</span><span style="color: #800000">"</span><span style="color: #000000">))
</span><span style="color: #008080">4</span> <span style="color: #0000ff">if</span> age ==<span style="color: #000000"> age_of_boy:
</span><span style="color: #008080">5</span>     <span style="color: #0000ff">print</span>(<span style="color: #800000">"</span><span style="color: #800000">you got it</span><span style="color: #800000">"</span><span style="color: #000000">)
</span><span style="color: #008080">6</span> <span style="color: #0000ff">elif</span> age ><span style="color: #000000"> age_of_boy:
</span><span style="color: #008080">7</span>     <span style="color: #0000ff">print</span>(<span style="color: #800000">"</span><span style="color: #800000">you need guess smaller</span><span style="color: #800000">"</span><span style="color: #000000">)
</span><span style="color: #008080">8</span> <span style="color: #0000ff">else</span><span style="color: #000000">:
</span><span style="color: #008080">9</span>     <span style="color: #0000ff">print</span>(<span style="color: #800000">"</span><span style="color: #800000">you need guess bigger</span><span style="color: #800000">"</span>)
Copier après la connexion

Masquer et afficher le mot de passe saisi

<span style="color: #008080">1</span> <span style="color: #0000ff">import</span><span style="color: #000000"> getpass
</span><span style="color: #008080">2</span> passwd = getpass.getpass(<span style="color: #800000">"</span><span style="color: #800000">input your password:</span><span style="color: #800000">"</span>)
Copier après la connexion
<span style="color: #008080"> 1</span> <span style="color: #008000">#</span><span style="color: #008000"> Author:dd</span>
<span style="color: #008080"> 2</span> <span style="color: #0000ff">import</span><span style="color: #000000"> getpass
</span><span style="color: #008080"> 3</span> 
<span style="color: #008080"> 4</span> 
<span style="color: #008080"> 5</span> _username = <span style="color: #800000">"</span><span style="color: #800000">test</span><span style="color: #800000">"</span>
<span style="color: #008080"> 6</span> _passwd = <span style="color: #800000">"</span><span style="color: #800000">111</span><span style="color: #800000">"</span>
<span style="color: #008080"> 7</span> 
<span style="color: #008080"> 8</span> username = input(<span style="color: #800000">"</span><span style="color: #800000">username:</span><span style="color: #800000">"</span><span style="color: #000000">)
</span><span style="color: #008080"> 9</span> passwd = getpass.getpass(<span style="color: #800000">"</span><span style="color: #800000">passwd:</span><span style="color: #800000">"</span><span style="color: #000000">)
</span><span style="color: #008080">10</span> <span style="color: #0000ff">print</span><span style="color: #000000">(username,passwd)
</span><span style="color: #008080">11</span> 
<span style="color: #008080">12</span> <span style="color: #0000ff">if</span> _username == username <span style="color: #0000ff">and</span> _passwd ==<span style="color: #000000"> passwd:
</span><span style="color: #008080">13</span>     <span style="color: #0000ff">print</span>(<span style="color: #800000">"</span><span style="color: #800000">user {name} login success</span><span style="color: #800000">"</span>.format(name=<span style="color: #000000">username))
</span><span style="color: #008080">14</span> <span style="color: #0000ff">else</span><span style="color: #000000">:
</span><span style="color: #008080">15</span>     <span style="color: #0000ff">print</span>(<span style="color: #800000">"</span><span style="color: #800000">login failed</span><span style="color: #800000">"</span>)
Copier après la connexion
<span style="color: #008080"> 1</span> <span style="color: #008000">#</span><span style="color: #008000"> Author:dd</span>
<span style="color: #008080"> 2</span> <span style="color: #0000ff">import</span><span style="color: #000000"> getpass
</span><span style="color: #008080"> 3</span> 
<span style="color: #008080"> 4</span> 
<span style="color: #008080"> 5</span> _username = <span style="color: #800000">"</span><span style="color: #800000">test</span><span style="color: #800000">"</span>
<span style="color: #008080"> 6</span> _passwd = <span style="color: #800000">"</span><span style="color: #800000">111</span><span style="color: #800000">"</span>
<span style="color: #008080"> 7</span> 
<span style="color: #008080"> 8</span> username = input(<span style="color: #800000">"</span><span style="color: #800000">username:</span><span style="color: #800000">"</span><span style="color: #000000">)
</span><span style="color: #008080"> 9</span> passwd = input(<span style="color: #800000">"</span><span style="color: #800000">passwd:</span><span style="color: #800000">"</span><span style="color: #000000">)
</span><span style="color: #008080">10</span> 
<span style="color: #008080">11</span> <span style="color: #0000ff">if</span> _username == username <span style="color: #0000ff">and</span> _passwd ==<span style="color: #000000"> passwd:
</span><span style="color: #008080">12</span>     <span style="color: #0000ff">print</span>(<span style="color: #800000">"</span><span style="color: #800000">user {name} login success</span><span style="color: #800000">"</span>.format(name=<span style="color: #000000">username))
</span><span style="color: #008080">13</span> <span style="color: #0000ff">else</span><span style="color: #000000">:
</span><span style="color: #008080">14</span>     <span style="color: #0000ff">print</span>(<span style="color: #800000">"</span><span style="color: #800000">login failed</span><span style="color: #800000">"</span><span style="color: #000000">)
</span><span style="color: #008080">15</span> <span style="color: #0000ff">print</span>(<span style="color: #800000">"</span><span style="color: #800000">ddd</span><span style="color: #800000">"</span>)
Copier après la connexion

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal