【发布时间】:2020-09-22 13:45:45
【问题描述】:
if results=='3':
with open("somerandomwords.txt") as f:
words = f.read().split()
word_dict = defaultdict(list)
for word, next_word in zip(words, words[1:]):
word_dict[word].append(next_word)
word="the"
while not word.endswith('.'):
await ctx.send(word)
time.sleep(2)
word = random.choice(word_dict[word])
await ctx.send(word)
time.sleep(50)
print('going')
每个单词都是自己发送的。我怎样才能使它形成句子(在不和谐的单个消息上发送单词)?
【问题讨论】:
-
你为什么要把它们插入字典?
-
你想把 somerandomwords.txt 中的单词粘在一起组成一个句子吗?
-
@YannickFunk 是的,谢谢你的澄清。我想用 somerandomwords.txt 中的一些词来造句。
-
你能提供几行你的txt文件吗?
标签: python python-3.x discord.py discord.py-rewrite