因此,今天我寫了一個相對幼稚的Python程序,用於在一段時間後在YouTube上打開娛樂視頻。更像是休息時間的事情,以便它從URL列表中隨機挑選一個。下面的代碼:編譯器在使用time.ctime()時返回無效語法錯誤
import os
import sys
import webbrowser
from time import *
import random
print("Hello! This program was started at " time.ctime())
totalBreaks = 5000
breaksTaken = 0
url = ['http://www.youtube.com/watch?v=OXWrjWDQh7Q', 'https://www.youtube.com/watch? v=yNLdblFQqsw', 'https://www.youtube.com/watch?v=tD4HCZe-tew', 'https://www.youtube.com/watch?v=GTyN-DB_v5M', 'https://www.youtube.com/watch?v=n49qi-dU9IE', 'https://www.youtube.com/watch?v=2iFa5We6zqw', 'https://www.youtube.com/watch?v=KEI4qSrkPAs', 'https://www.youtube.com/watch?v=yzTuBuRdAyA', 'https://www.youtube.com/watch?v=_kqQDCxRCzM', 'https://www.youtube.com/watch?v=u2cphuMbqfc']
while (breaksTaken > totalBreaks) :
time.sleep(60)
webbroswer.open(choice.random(url))
您的打印錯過了一個逗號,你的'while'塊不是縮進。 –
Python編譯器,lolwut。 –
@PeterNimroot呢? –