Python如何实现跑马灯文字效果输出
1、用 import 代码导入模块 tiem 和 osimport timeimport os
2、建立一个变量,名称为C 赋值我们想要输出的文字,代码如下:c = "hello python"
3、建立一个while 循环,条件设置为真,具体代码如下:while 1:
4、在while循环下面写上如下代码:time.sleep(0.5)os.system猾诮沓靥("cls")c = c[1:] + c[0]print(c)
5、之后我们找到写好的python文件,用cmd窗口运行,效果如图
6、整体代码总窑钕仇焱结:import timeimport osc = "hello python"while 1: tim髫潋啜缅e.sleep(0.5) os.system("cls") c = c[1:] + c[0] print(c)
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:67
阅读量:90
阅读量:88
阅读量:83
阅读量:68