2
我寫了下面的代碼語法錯誤:非ASCII字符 ' XD1'
conAcc = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=D:\ThirdTask\Northwind.accdb')
SqlAccess=conAcc.cursor();
SqlAccess.execute(sql.sql_count_record_clients);
CountOfRecords=SqlAccess.fetchone();
conAcc.close();
那裏是在模塊sql.py
sql_count_records_clients='''SELECT COUNT(*) FROM "Список клиентов"'''
行結果,該行SQL。 py給出錯誤
Traceback (most recent call last):
File "D:\ThirdTask\connect.py", line 5, in <module>
import json,sqlite3,sql
File "D:\ThirdTask\sql.py", line 48
SyntaxError: Non-ASCII character '\xd1' in file D:\ThirdTask\sql.py on line 48, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
應該怎麼做才能使錯誤消失?
你的錯誤消息說,這一切:你讀過[PEP263(http://www.python.org/ PEPS/PEP-0263.html)? –
可能是這個http://stackoverflow.com/questions/18078851/syntaxerror-of-non-ascii-character –