3

我写了以下代码

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

应该怎么做才能使错误消失?

4

1 回答 1

4

需要添加第一行代码:

# -*- coding: utf-8 -*- 
enter code here

然后问题解决

于 2016-01-24T15:03:18.460 回答