简体   繁体   中英

How can i fix my code to solve this syntax error in my config.py?

I create config.py file and run my Python code and it shows syntax error.

#config.py
API_key = GTW89NF3
mac = mac=6c:rf:7f:2b:0e:g8

File "flaskapp.py", line 8, in <module>
from config import API_KEY
File "/home/ubuntu/flaskapp/config.py", line 4
mac = mac=6c:rf:7f:2b:0e:g8
            ^
SyntaxError: invalid syntax

Why do you write mac = 2 times ?

Try going with one of these depending on what you want to achieve:

mac = "6c:rf:7f:2b:0e:g8"

Or

mac = "mac=6c:rf:7f:2b:0e:g8"

a config.py file usually has to be syntactically valid Python.

In Python, values that are strings need quotes around them:

API_KEY = "GTW89NF3"
mac = "6c:rf:7f:2b:0e:g8"

Also, it looks like the Flask app that you are using uses a config item called API_KEY , not API_key ; generally Python is case sensitive.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM