下面的代码片段正在生成“奇怪”的输出:
for s in servers:
vo = ss.getServerVO(s)
values = []
for f in voFields:
attribValue = getattr(vo, f)
values.append(attribValue)
customValues = ss.getCustomFields(s)
for f in customFields:
values.append(customValues[f])
# Convert all values to string before writing
values = map(str, values)
csvFile.writerow( values )
对于字典中的某些(不是全部)项目customFields
,我得到以下输出:
<bound method ServerVO.getCreatedDate of <pytwist.com.opsware.server.ServerVO instance at 0x3da8680>>
我需要做什么才能让绑定的方法执行/将其结果放入我的values
字典中?
(具体上下文是针对 HP Server Automation API 编写 PyTwist 脚本)