我写了这段非常基本的代码。当我运行它时,else语句不起作用。三个if语句获得正确的网页并打印报表就好了。
import webbrowser
import time
breaks = 3
breaks_taken = 0
if(breaks_taken == 0):
breaks_taken = breaks_taken + 1
time.sleep(5)
webbrowser.open('https://www.youtube.com/watch?v=R03cqGg40GU')
print('this program was started at ' + time.ctime())
if(breaks_taken == 1):
breaks_taken = breaks_taken + 1
time.sleep(5)
webbrowser.open('https://www.youtube.com/watch?v=AfuCLp8VEng')
print('this program was started at ' + time.ctime())
if(breaks_taken == 2):
breaks_taken = breaks_taken + 1
time.sleep(5)
webbrowser.open('https://www.youtube.com/watch?v=-MsvER1dpjM')
print('this program was started at ' +time.ctime())
else:
print('this is your final break')