"/> ">
Heim >Backend-Entwicklung >Python-Tutorial >Wenn sonst Prozessurteil – KLASSE 11 (Teil 1)
wenn Urteilserklärung
<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>)
Erraten Sie Ihr Alter
<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>)
Das eingegebene Passwort ausblenden und anzeigen
<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>)
<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>)
<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>)
Das obige ist der detaillierte Inhalt vonWenn sonst Prozessurteil – KLASSE 11 (Teil 1). Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!