Python - 使用 gspread 在 Google Drive 的特定文件夹中创建电子表格
Python - Using gspread to create a spreadsheet in a specific folder in Google Drive
我正在尝试使用 gspread 创建一个新的电子表格,我希望能够控制它的最终位置。
gc = gspread.authorize(credentials)
sheetname = 'Test sheet'
sheet = gc.create(sheetname)
我认为发生的事情是,当我执行 gc.create(sheetname) 时,它会出现在我的 Google 服务帐户中,但我希望它最终出现在我的特定文件夹中普通账户。
-
--想通了--
需要更改为以下内容:
if parent_folder_ids:
body["parents"] = parent_folder_ids
你可以参考这个tutorial。
def create_google_spreadsheet(title: str, parent_folder_ids: list=None, share_domains: list=None) -> Spreadsheet:
"""Create a new spreadsheet and open gspread object for it.
请注意,创建的电子表格不会立即显示在您的云端硬盘搜索中,您需要通过直接 link 访问它。
我正在尝试使用 gspread 创建一个新的电子表格,我希望能够控制它的最终位置。
gc = gspread.authorize(credentials)
sheetname = 'Test sheet'
sheet = gc.create(sheetname)
我认为发生的事情是,当我执行 gc.create(sheetname) 时,它会出现在我的 Google 服务帐户中,但我希望它最终出现在我的特定文件夹中普通账户。
-
--想通了--
需要更改为以下内容:
if parent_folder_ids:
body["parents"] = parent_folder_ids
你可以参考这个tutorial。
def create_google_spreadsheet(title: str, parent_folder_ids: list=None, share_domains: list=None) -> Spreadsheet:
"""Create a new spreadsheet and open gspread object for it.
请注意,创建的电子表格不会立即显示在您的云端硬盘搜索中,您需要通过直接 link 访问它。