Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PythonL: invalid syntax file "<fstring>", line 1

Tags:

When doing python3 Webhook.py (this is the file), it gives me the error: File "<fstring>", line 1 (%X - %x) ^ SyntaxError: invalid syntax

I've tried to print out the raw contents of the file and I also used a hex editor, there is nothing on line 1 that should be causing erorrs. I also did: import time, os, aiohttp, plistlib, discord, asyncio, json, subprocess In the Terminal.app version of Python3 and I had no errors, my version was 3.6.3 but updated to 3.6.5 to check if the issue would go away, which didn't. Can anyone help?

like image 456
incredaboy Avatar asked Mar 30 '18 22:03

incredaboy


1 Answers

I just spent 1 hour reviewing my code with the same issue. In my case I started removing parts of the code to narrow down the problem.

Finally I to the root cause of the problem.

in my case I was printing an f"string" and inside the f string I had a space in the name of the variable I was calling example print(f"This is a statement {Var 23} "

That space, generated my problem.

I hope this helps :)

like image 164
Ignacio Avatar answered Oct 22 '22 03:10

Ignacio