0
我正在尋找一種訪問單元歷史元素的方法。我已經使用了以下代碼的各種迭代來獲取單元格歷史字典中的鍵,但是我(顯然)做錯了什麼。當運行下面的代碼時,我得到這個錯誤 - TypeError: 'CellHistory' object has no attribute '__getitem__'
訪問單元格歷史(python,smartsheets)
幫助!這真讓我抓狂!
#get the cell history
action = smartsheet.Cells.get_cell_history(
sheetid,
sheet.rows[1].id,
columns[1].id,
include_all=True)
revisions = action.data
#print out something from revision history
for rev in revisions:
print rev['modifiedAt'] #breaks here`
嘗試'打印(rev.modifiedAt)' - 現在越來越 「AttributeError的:modifiedAt」 任何其他的想法? –
嘗試modified_at(其參考文獻不是API文檔中的內容)並取得了成功。謝謝! –
樂意幫忙!以供將來參考:Smartsheet API文檔中描述的任何屬性(並不特別出現在Python代碼示例中)表示屬性在API(JSON)請求/響應中的顯示方式。 Python SDK使用Python變量命名約定:「爲了提高可讀性,用小寫字母分隔下劃線」(如下所述:https://www.python.org/dev/peps/pep-0008/)。例如,原始API響應可能包含屬性「modifiedAt」 - 但通過Python SDK使用此屬性時,您會將其稱爲「modified_at」。 –