如何使用python获取文件夹中的工作表ID数组 [英] How to get the array of sheet ids in a folder with python
问题描述
当我尝试通过get.folder()调用获取id数组(通过使用folder = folder.sheets.id)时,得到的答案是:"AttributeError:'TypedList'对象没有属性'id'"我不确定要在python中调用什么函数来获取文件夹中的工作表ID数组.
When I try to get the id array from the get.folder() call (by using folder = folder.sheets.id), I get the answer: "AttributeError: 'TypedList' object has no attribute 'id'" I'm not sure what function to call in python to get the array of sheet ids in the folder.
我正在尝试使用python smartsheet sdk进行此操作,但是我不确定如何格式化它.
I am trying to do this with the python smartsheet sdk, but I am not sure exactly how to format it.
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)
也感谢您帮助回答我的问题,我真的很感激.
Also thanks for helping answer my questions, I really appreciate it.
推荐答案
folder.sheets
是一个数组.出现错误的原因是因为数组级别没有id
属性-您需要查看数组中的各个元素.
folder.sheets
is an array. The reason you're getting an error is because there is no id
attribute at the array level - you need to look at the individual elements inside the array.
看看 API文档以获取您将收到的示例.
Take a look at the API docs to get an example of what you'd receive.
sheet_ids = []
for sheet in folder.sheets
sheet_ids.append(sheet.id)
print(sheet_ids)
这篇关于如何使用python获取文件夹中的工作表ID数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!