AttributeError:'str'对象没有属性'iteritems'

时间:2012-11-09 20:53:43

标签: attributeerror

我正在尝试编写一个会写入Google文档电子表格的脚本,当我运行它时,我会在标题中看到错误。更具体地说:

File "/home/pi/Desktop/templog.py", line 44, in <module>
    s.run()
  File "/usr/lib/python2.7/sched.py", line 117, in run
    action(*argument)
  File "/home/pi/Desktop/templog.py", line 35, in do_something
    entry = spr_client.InsertRow(data_str, spreadsheet_key, worksheet_id)
  File "/usr/local/lib/python2.7/dist-packages/gdata/spreadsheet/service.py", line 330, in          InsertRow
for k, v in row_data.iteritems():
AttributeError: 'str' object has no attribute 'iteritems'

造成这种情况的代码是:

entry = spr_client.InsertRow(data_str, spreadsheet_key, worksheet_id)
        if isinstance(entry, gdata.spreadsheet.SpreadsheetsList):

1 个答案:

答案 0 :(得分:1)

不,导致错误的行是row_data.iteritems(),因为row_data是一个字符串,并且没有为'str'类定义你正在调用的方法。