我正在编写一个支持语音的个人助手,它可以发送电子邮件、查看天气和打开网站。
我正在使用Google Voice API将我的语音转换为文字。当我说“Open funny dot reddit dot com”时,Google会将其识别为'Funny.Reddit.com'。因此,我需要一种方法,使点号之前的任何内容与.com的字符串合并。
我正在使用Google Voice API将我的语音转换为文字。当我说“Open funny dot reddit dot com”时,Google会将其识别为'Funny.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 for s in text if '%s.' in s)
会通过换行符将单词或字符连接起来。你的意图不是创建有效的URL吗? - jDo