Keep-getingNonetype没有属性头



这是产生错误的代码:

dict1 = {
"requestId": "32",
"records": {
"totalRecords": 5,
"currentPageSize": 5,
"currentPageNumber": 1
}
}
j3 = dict1.get("totalRecords")
j3.head()

获取总记录的代码需要首先获取"像这样的记录:

j3 = dict1.get("records").get("totalRecords")

这是一个嵌套的字典,所以你需要先得到包含它的字典。

head((函数调用仍然会出现错误,因为int没有为其定义该函数(5是int(

最新更新