Home > Blockchain >  How do I fix this weird python syntax error?
How do I fix this weird python syntax error?

Time:11-27

import discord
from discord.ext import commands
import secrets
from secrets import TOKEN

client = discord.Client()

@client.event
async def on_ready():
    print("Bot is ready.")

client.run(f"{TOKEN}")

I'm using VSC and I just wrote this code into my main file. I'm not sure why but it keeps saying:

File "<stdin>", line 1
    ▬▬▬& C:/Users/username/AppData/Local/Programs/Python/Python311/python.exe c:/Users/username/OneDrive/Desktop/PythonCode/main.py
    ^
SyntaxError: invalid non-printable character U 0016

Anyone know what would be the cause of it?

CodePudding user response:

Your Python file seems perfectly fine from a syntax point of view. This WebRepl has no problem parsing it: https://www.online-python.com/LE9maKwF8z . (It can't find discord, but that's fine and the syntax is ok).

It looks like a VSC problem. Try saving the file and run it with

python3 main.py

to validate that's it is a VSC problem.

CodePudding user response:

find the Unicode Character (U 0016) in main.py with a text editor ,delete it and save the file.

  • Related