我正在编程一个支持语音的个人助理。它可以发送电子邮件,检查天气,并打开网站。合并两个列表项的条件
我使用Google Voice API将我的声音转换为语音。当我说“Open funny dot reddit dot com”时,Google认为它是“有趣的”。 Reddit.com。”所以,我需要一种方法之前,做出这等事情‘’,是与.COM的字符串相结合。
text = ['open', 'funny.', 'Reddit.com']
if 'open' in text:
print(text)
text = text.split()
sub = 'com'
www = 'www'
wcheck = ("\n".join(s for s in text if www in s))
website = ("\n".join(s for s in text if sub in s))
if 'www' in wcheck:
web.open(website)
if 'www' not in wcheck:
web.open('www.' + website)
prefix =“\ n”.join(s代表s中文本中的s) – Will
我不完全确定你想要实际做什么。 'prefix =“\ n”。如果's'中的'%s。''加入(s代表文本中的s)'将通过换行符连接单词或字符。您不打算创建有效的网址吗? – jDo
我的坏,我只是不知道该怎么办 – Will