【发布时间】:2021-07-13 04:08:07
【问题描述】:
我正在开发一个可与 google drive api 和 google sheet 一起使用的 selenium 项目,但我需要将我的项目作为 .exe 文件运行,因此我使用 pyinstaller 对其进行了转换,它运行良好,但是当我尝试将其移至另一个时PC,用不同的gmail帐户,输入了新的google sheet name和worksheet name,它没有识别它们,但是识别了过去电子邮件中的旧文件,怎么回事?换句话说,selenium 会看到哪个账户,默认的还是当前的?
import gspread
from oauth2client.service_account import ServiceAccountCredentials
def sheet_access(sheet_name, worksheet_name):
scope = ['https://www.googleapis.com/auth/spreadsheets', "https://www.googleapis.com/auth/drive.file",
"https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
client = gspread.authorize(creds)
sheet = client.open(sheet_name).worksheet(worksheet_name)
return sheet
【问题讨论】: