【问题标题】:how to correct the indent for this line? [closed]如何更正这一行的缩进? [关闭]
【发布时间】:2021-07-16 16:03:47
【问题描述】:

我在网上学习了一个教程:https://www.freecodecamp.org/news/create-a-discord-bot-with-python/ 我不能让机器人在线。有人可以帮忙吗?

它将运行关于秘密的错误(秘密是令牌,我在复制时这样做了) 我知道错误是关于秘密处的缩进,但是放在哪里?

错误:

File "main.py", line 8
    client.run(my_secret)
    ^
     

下面是代码。请帮助thks

import os
import discord
my_secret = os.environ['TOKEN']


client = discord.Client()
  client.run(my_secret)

@client.event
async def on_ready():
  
  print('We have logged in as {0.user}'
  .format(client))

@client.event
async def on_message(message):
  if message.author == client.user:
    return
      
  if message.content.startswith('$start'):
    await message.channel.send('Hello!')

【问题讨论】:

  • 你正在用 python 编写。当然,您应该知道缩进非常重要。去掉client.run(my_secret)后面的空格。

标签: python discord bots


【解决方案1】:

只需删除client.run(my_secret)之前的空格

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-26
    • 1970-01-01
    • 2013-06-21
    • 2012-02-21
    • 2010-11-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多