我正在尝试构建一个基于文本的虚拟助手,但问题是我不知道如何使用 pywhatkit playonyt 和搜索命令,以便用户输入播放......(任何歌曲或视频)和搜索(无论他们想搜索什么)如果可以,请提供帮助:)))
代码:
def take_command():
command = input("Tell me what would you like me to do").format()
song = pywhatkit.playonyt()
if command in ('play', 'search'):
if command == 'play'+:
答案 0 :(得分:0)
试试这个:
import pywhatkit
command = input("Tell me what would you like me to do: ").lower()
if "play" in command:
pywhatkit.playonyt(command.replace("play ",""))
if "search" in command:
pywhatkit.search(command.replace("search ",""))
它检查 command 是否包含特定的单词,如果是,则删除它们并将短语的其余部分传递给函数。