python编程练习--跑马灯

python编程练习--跑马灯 

import os
import time

def main():
    content = '5201314......'
    count = 0
    while True:
        os.system('cls') #清理屏幕
        print(content)
        time.sleep(0.5)  #休眠500ms
        content = content[1:] + content[0]
        count += 1
        if count > 5:
            break
main()

输出结果:

5201314......

201314......5

01314......52

1314......520

314......5201

14......52013

你可能感兴趣的:(python)