用python制作出‘逐字输出’的效果
1、新建一个文本文档,把后缀名改成 ‘.py’
2、用VSCode打开
3、输入代码:
4、#code:CNTS
import sys,time
def print_one_by_one(text): #此处的print_one_by_one可以自定义名称
sys.stdout.write("\r " + " " * 60 + "\r") #/r 光标回到行首, \n 换行
sys.stdout.flush() # 把缓冲区全部输出
for c in text:
sys.stdout.write(c)
sys.stdout.flush()
time.sleep(0.1)
print_one_by_one("hello word!\n") #如果上面的自定义,下面要保持一致
print_one_by_one("hello word!\n")
5、如果觉得打字速度太快,那么调这里:(粗体字,照片里是蓝色光标划出)
t.sleep(0.1)
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:55
阅读量:154
阅读量:73
阅读量:133
阅读量:71