代码完全在pycharm中工作,但部分在树莓上工作

时间:2017-06-01 20:38:26

标签: python raspberry-pi pygame

当我要求pycharm运行它时,程序的所有内容都有效。 但当我问我的覆盆子Pi运行它时,它会跳过EndTimer。所以这首歌继续播放。在Windows上,歌曲会停止。什么能让这个小小的差异?

import datetime
import pygame

def Clockupdate(time):
    Timer = "21:56:00"
    EndTimer = '21:56:20'
    if time == Timer:
        playsound()
    if time == EndTimer:
        global a
        a = False
def secondrefresher():
    newtime = ""
    oldtime = datetime.datetime.now()
    a = str(oldtime.hour)
    b = str(oldtime.minute)
    c = str(oldtime.second)
    if int(c) < 10:
        c = "0"+str(c)
    if int(b) < 10:
        b = "0"+str(b)
    curtime = (a+":"+b+':'+c)
    if curtime != newtime:
        newtime = curtime
        Clockupdate(newtime)

def playsound():
    pygame.mixer.init()
    pygame.mixer.music.load("ABTPP.mp3")
    pygame.mixer.music.play()

global a
a = True

while a:
    secondrefresher()

0 个答案:

没有答案