Python+turtle realizes a picture player

We can use Python+turtle to implement a simple picture player, let's take a look at the rendering

Please add a picture description

Full version code:

['D:\照片\\' + i for i in os.listdir('D:\照片')]: os.listdir('write here the path to save your pictures')

Screen().bgpic(pic_list[num]), load the picture to the window of the turtle

Screen().update(), refresh the window

ontimer(run, 1000), here is the interval time, in milliseconds

import os
from turtle import *

pic_list = ['D:\照片\\' + i for i in os.listdir('D:\照片')]
num = 0
def run():
    global num
    if num > 4:
        num = 0
    Screen().bgpic(pic_list[num])
    Screen().update()
    num += 1
    ontimer(run, 1000)

run()
done()

Very simple little code, hope it can help you

A little programmer dedicated to office automation#

I've seen this, follow + like + bookmark = don't get lost! !

If you want to know more about Python office automation, please pay attention!

Guess you like

Origin blog.csdn.net/weixin_42636075/article/details/132605845