Created
December 20, 2018 16:05
-
-
Save caoya171193579/c4582226127779547381504e073bb238 to your computer and use it in GitHub Desktop.
进阶
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for循环是有次数的,不是无限循环的。 | |
while循环: 可以在不阻断的情况下无限循环。 | |
while循环,循环直到表达式为假,表达的十一逻辑表达式,必须返回一个True或False值。 | |
(一定要设置一个结束的参数,不然会一直死循环,把CPU 占满的。) | |
1、 | |
 | |
root@kali:~/xuexi# python 8.py | |
no,hello | |
please input num,输入一个值代表x,如果遇到w就会结束循环:a | |
one more time~~~~~~~ | |
no,hello | |
please input num,输入一个值代表x,如果遇到w就会结束循环:a | |
one more time~~~~~~~ | |
no,hello | |
please input num,输入一个值代表x,如果遇到w就会结束循环:w | |
one more time~~~~~~~ | |
no,no...... | |
当输入的字符是w的时候会结束这个循环,不会再执行下面的代码。 | |
2、 | |
 | |
root@kali:~/xuexi# python 8.py | |
no,hello | |
please input num,输入一个值代表x,如果遇到w就会结束循环:q | |
one more time~~~~~~~ | |
no,hello | |
please input num,输入一个值代表x,如果遇到w就会结束循环:w | |
one more time~~~~~~~ | |
no,no...... | |
当输入到w的时候循环就会结束,nono......结尾 | |
3、 | |
 | |
root@kali:~/xuexi# python 8.py | |
no,hello | |
please input num,输入一个值代表x,如果遇到w就会结束循环:a | |
one more time~~~~~~~ | |
no,hello | |
please input num,输入一个值代表x,如果遇到w就会结束循环:1 | |
one more time~~~~~~~ | |
no,hello | |
please input num,输入一个值代表x,如果遇到w就会结束循环:221312 | |
one more time~~~~~~~ | |
no,hello | |
please input num,输入一个值代表x,如果遇到w就会结束循环:y | |
no,hello | |
please input num,输入一个值代表x,如果遇到w就会结束循环: | |
当循环输入y 的时候,循环就会跳过当前代码组。 当敲回车的时候等于为空值了,也立马结束了所有代码。 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment