import random
from words import voc_list
import time
from plyer import notification
def get_word():
word = random.choice(voc_list)
return word.upper()
if __name__ == "__main__":
while True:
notification.notify(
title = "Here is another vocablary word :-"
The_word = random.choice(voc_list)
Timeout = 8
)
我正尝试发出词汇提醒,每2小时告诉你一个新单词。我列出了单词及其含义,并想随机显示我从单词import voc_list中使用的任何单词,但是为什么这里显示为无效语法The_word = random.choice(voc_list)
我认为你在notify
方法中传递了多个参数,并且缺少参数的逗号。
import random
from words import voc_list
import time
from plyer import notification
def get_word():
word = random.choice(voc_list)
return word.upper()
if __name__ == "__main__":
while True:
notification.notify(
title = "Here is another vocablary word :-",
The_word = random.choice(voc_list),
Timeout = 8
)
如果你正确使用了导入的模块,则应该可以使用。