我正在尝试做这样的事情:
import pygsheets
from oauth2client.service_account import ServiceAccountCredentials
scope = [
'https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive'
]
credentials01 = ServiceAccountCredentials.from_json_keyfile_name('creds01.json', scope)
def make_connection():
global file01
file01 = pygsheets.client.Client(credentials01)
def fetch_data():
wb01 = file01.open('Database System 2')
make_connection()
fetch_data()
但是,它引发了一个名称错误,即“未定义file01”。有什么办法可以解决吗?