我们可以通过 for 循环 和 format 的配合来进行动态输出
代码:
import time #导入 time 模块
text = ['a','b','c'] #动态输出的文字(可根据需求修改)
for i in text: # for 循环
print('\r动态输出:{}'.format(i),end = '')
#大括号内为动态变化的内容,内容以列表形式填写在 format 里
time.sleep(1) #输出间隙
通过动态输出和获取时间的结合,我们也可以进行动态报时
代码示例 :
#导入模块
import time as tm
import json as js
import requests as re
import datetime as dt
import calendar as cl
def data(): #获取时间
year = int(tm.strftime("%Y", tm.localtime()))
month = int(tm.strftime("%m", tm.localtime()))
mint = int(tm.strftime("%M", tm.localtime()))
sec = int(tm.strftime("%S", tm.localtime()))
hour = int(tm.strftime("%H", tm.localtime()))
f = int(dt.datetime.now().strftime('%f'))/1000
hm =str


633

被折叠的 条评论
为什么被折叠?



