Error in user YAML: (<unknown>): could not find expected ':' while scanning a simple key at line 3 column 1
---
- oeasy Python 0169
- 这是 oeasy 系统化 Python 教程,从基础一步步讲,扎实、完整、不跳步。愿意花时间学,就能真正学会。
本教程同步发布在:
个人网站: `https://oeasy.org`
蓝桥云课: `https://www.lanqiao.cn/courses/3584`
GitHub: `https://github.com/overmind1980/oeasy-python-tutorial`
Gitee: `https://gitee.com/overmind1980/oeasypython`
---- 上次初步了解了死循环
- while True:
- 可以设置
- 各种各样的颜色
- 让屏幕 五彩嫔纷
- 也可以让屏幕黑白变化
- 你还能做出什么样好玩的效果吗?
- 录下来
- 记录这一刻吧!
- 能否让屏幕
- 按照字节的方式
- 也就是8-bit一组的方式
- 变化颜色呢?🤔
from random import randint
color = 0
count = -1
print("\33[0m")
while True:
num = randint(0, 1)
if (count == 7):
count = -1
if color == 0:
color = 7
else:
color =0
print("\33[" + str(color) + "m" + str(num), end="")
count = count + 1
- 这个程序可以调试吗?
- 直接进入循环
- c 起来之后
- 就直接死循环进行
- 如何设置条件格式?
- 首先有断点
- 然后在断点上设置条件
- condition
- 设置了条件断点
- 每次count到7的时候
- 就会反转颜色了
- 可以让颜色更多一些吗?
from random import randint
color = 40
count = -1
print("\33[0m")
while True:
num = randint(0, 1)
if (count == 7):
count = -1
color = color + 1
if color == 48:
color = 40
print("\33[" + str(color) + "m" + str(num), end="")
count = count + 1
num = num + 1
- 结果
- 尝试设置断点
- 设置条件断点
- 继续
- 颜色八位一换
- 去总结吧
- 这次调试了死循环
- 使用了条件断点
- condition bpnumber [condition]
- 只有符合条件的时候
- 才会启动断点
- 循环必须得死吗?
- 有没有循环不死的方式呢?🤔
- 下次再说 👋
- 本文来自 oeasy Python 系统教程。
- 想完整、扎实学 Python,
- 搜索 oeasy 即可。










