【发布时间】:2020-09-07 15:19:00
【问题描述】:
当我尝试运行我的代码时,出现此错误:\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe: can't find '\_\_main\_\_' module in ''
我不知道如何解决它。我看过与我类似的帖子,但他们的修复似乎不起作用。这是我所有的代码:
import discord
client = discord.client()
@client.event
async def on_ready():
print(f"we have logged in as {client.user}")
client.run("my bot token would be here")
@client.event
async def on_message(message): # event that happens per any message.
# each message has a bunch of attributes. Here are a few.
# check out more by print(dir(message)) for example.
print(f"{message.channel}: {message.author}: {message.author.name}: {message.content}")
client.run(token) # recall my token was saved!
@client.event
async def on_message(message): # event that happens per any message.
print(f"{message.channel}: {message.author}: {message.author.name}: {message.content}")
if str(message.author) == "hello" in message.content.lower():
await message.channel.send('hi')
【问题讨论】:
-
你安装了discord lib吗?和蟒蛇?您能否提供有关您的环境和执行的更多信息?此外,我强烈建议您更改为 Unix 环境。
-
discord lib 和 python 都已安装。我正在使用崇高的文本,所以我只需编写代码并运行,剩下的就交给我了。我对编码很陌生
-
请发布完整的回溯。我们需要详细信息。
-
我不太清楚你的意思,我所有的代码都在那里。如果你是这个意思,这里是完整的错误。 C:\Users\zorbs\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe:在“”中找不到“main”模块
-
@NoHaxJustEncrypted - 很有趣。这表明该脚本从未运行过,问题出在您的安装上。