没有__dict__的Python打印属性 [英] Python printing attributes with no __dict__

查看:209
本文介绍了没有__dict__的Python打印属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用python脚本桥时遇到了麻烦

I am having trouble with scripting bridge for python

我正在尝试列出iTunes对象的属性

I am trying to list the attributes of the iTunes object

iTunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")

使用

>>> from pprint import pprint
>>> from Foundation import *
>>> from ScriptingBridge import *
>>> iTunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")
>>> pprint (vars(iTunes))

我回来

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: vars() argument must have __dict__ attribute

有人知道如何解决这个问题吗?

anyone know how to get around this?

推荐答案

尝试dir(iTunes).它与vars相似,但更直接用于对象.

Try dir(iTunes). It's similar to vars, but more directly used with objects.

这篇关于没有__dict__的Python打印属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆