我尝试从Google速度表中获取数据
from __future__ import print_function
import gspread
from oauth2client.client import SignedJwtAssertionCredentials
import pandas as pd
import numpy as np
from numpy import nan
import json
我愿意
SCOPE = ["https://spreadsheets.google.com/feeds"]
SECRETS_FILE = "D:.......json"
SPREADSHEET = "sheet"
和
json_key = json.load(open(SECRETS_FILE))
credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], SCOPE)
gc = gspread.authorize(credentials)
workbook = gc.open(SPREADSHEET)
sheet = workbook.sheet1
db = pd.DataFrame(sheet.get_all_records())
db.head()
我明白了
----> 6 db = pd.DataFrame(sheet.get_all_records())
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 2039: invalid continuation byte
我尝试过
import sys
from importlib import reload
reload(sys)
sys.setdefaultencoding("utf-8")
AttributeError: module 'sys' has no attribute 'setdefaultencoding'
我使用
print (sys.version)
3.5.4 |Anaconda custom (64-bit)| (default, Aug 14 2017, 13:41:13) [MSC v.1900 64 bit (AMD64)]
我尝试了
import os
os.environ["PYTHONIOENCODING"] = "utf-8"
,没有结果。我想问题可能出在我更新了Python版本