Python如何实现跑马灯文字效果输出
的有关信息介绍如下:
Python可以做很多事情,今天我们一起看一下如何用Python实现跑马灯文字效果
用 import 代码导入模块 tiem 和 os
import timeimport os
建立一个变量,名称为C 赋值我们想要输出的文字,代码如下:
c = "hello python"
建立一个while 循环,条件设置为真,具体代码如下:
while 1:
在while循环下面写上如下代码:
time.sleep(0.5)os.system("cls")c = c[1:] + c
print(c)
之后我们找到写好的python文件,用cmd窗口运行,效果如图
整体代码总结:
import timeimport osc = "hello python"while 1: time.sleep(0.5) os.system("cls") c = c[1:] + c print(c)



