4

当我尝试从 get.folder() 调用中获取 id 数组时(通过使用 folder = folder.sheets.id),我得到了答案:“AttributeError: 'TypedList' object has no attribute 'id'”我是不确定在 python 中调用什么函数来获取文件夹中的工作表 ID 数组。

我正在尝试使用 python smartsheet sdk 执行此操作,但我不确定如何格式化它。

inc_list = ['all'] # you can add other parameters here, separated by a comma
 response = ss_client.Folders.copy_folder(
  folderID,                           # folder_id
  ss_client.models.ContainerDestination({
    'destination_id': destinationID,
    'destination_type': 'folder',
    'new_name': cellValue
  }),
include=inc_list
)

copiedFolderID = response.result.id

folder = ss_client.Folders.get_folder(
  copiedFolderID)       # folder_id 

newFolder = folder.sheets.id

print (newFolder)

也感谢您帮助回答我的问题,我真的很感激。

4

2 回答 2

3

folder.sheets是一个数组。您收到错误的原因是因为id在数组级别没有属性 - 您需要查看数组中的各个元素。

查看API 文档以获取您将收到的示例。

sheet_ids = []
for sheet in folder.sheets
    sheet_ids.append(sheet.id)
print(sheet_ids)
于 2018-08-02T18:16:05.003 回答
1

要获取文件夹中工作表的 sheetId 列表,您的 Python 将如下所示。

my_folder = ss_client.Folders.get_folder(folder_id)

for sheet in my_folder.sheets:
    print(sheet.id)
于 2018-08-02T18:11:33.053 回答