TypeError:类型' _io.TextIOWrapper'的对象没有len()

时间:2017-09-29 11:36:03

标签: python discord

我有这段代码:

emailFile = open("C:/Users/jacob/Downloads/Spotify_premiums.txt", "r")
emails = []
for email in emailFile:
    emails.append(email)

@bot.command(pass_context = True)
@commands.cooldown(1, 30, commands.BucketType.user)
@commands.has_any_role("| Premium |")
async def spotifypremium(ctx):
    msg = emailFile
    await bot.send_message(ctx.message.author, random.choice(msg))
    await bot.send_message(ctx.message.channel, "Alt Has Been Seen To Your DMs")
    await bot.purge_from(ctx.message.channel, limit=2)
    await bot.send_message(ctx.message.author, "Please Wait 30 Seconds Before Using This Command Again. If you do not wait the full time then you won't be sent an alt.")

我收到错误TypeError:type' _io.TextIOWrapper'没有len()...我试图使用文本文件而不是冗长的msg变量。我希望机器人使用文本文件中的随机行并通过DM发送它。

0 个答案:

没有答案