N
N
Nolrox2021-01-21 15:57:14
Python
Nolrox, 2021-01-21 15:57:14

What to do if, when developing a bot, he writes something about Non-UTF-8?

I am writing a bot on discord.py, python 3.8.2, here is the code:

import discord
from discord.ext import commands
from config import settings

bot = commands.Bot(command_prefix = settings['prefix'])

@bot.command() 
async def hi(ctx):
    author = ctx.message.author
    await ctx.send(f'Привет, {author.mention}!')

bot.run(settings['token'])

when I run it it says SyntaxError: Non-UTF-8 code starting with '\xf2' in file C:\Users\Gleb\Desktop\bot\main.py on line 10, but no encoding declared; see python.org/dev/peps/pep-0263 for details

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Shitskov, 2021-01-21
@Zarom

Most likely, the launch is not done through python 3.8.2, but through python 2.3

A
AVKor, 2021-01-21
@AVKor

SyntaxError: Non-UTF-8 code starting with '\xf2' in file C:\Users\Gleb\Desktop\bot\main.py on line 10, but no encoding declared;

What word is not clear here?
The link also says: either use UTF-8 encoding or specify it explicitly at the beginning of the script (apparently, CP-1251 is used).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question