我试着从谷歌速度表上获取数据
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版本
目前没有回答
相关问题 更多 >
编程相关推荐