- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
这种情况经常发生。一个函数返回一个我无法读取的对象。这里:
discoverer = GstPbutils.Discoverer()
discoverer.connect('discovered', on_discovered)
info = discoverer.discover_uri(self.loaded_file)
print(vinfo.get_tags())
返回这个:
<Gst.TagList object at 0x7f00a360c0a8 (GstTagList at 0x7f00880024a0)>
但是当我尝试这样做时:
tags = vinfo.get_tags()
for tag in tags:
print (tag)
我明白了:
TypeError: 'TagList' object is not iterable
但是当我读到 the doc of this data structure ,我好像明白了是……列表?除了告诉我如何获取标签之外,有人可以告诉我如何阅读那些文档吗?另外,我是否缺少一些内省(introspection)方法和工具,我可以用它们来发现我遇到的对象是什么,以及它们是如何工作的?
最佳答案
这都是假设,因为我从未将 python 与 GStreamer 一起使用:
根据文档 - 是的,它是说它的列表..但这可以表示为内部结构..记住 python 绑定(bind)只是..绑定(bind) - 它的工作方式与以下类似(如果没有以更好的方式实现) C.. 你在C with tags to iterate them 做什么? .. 但不要问我是怎么发现的——你必须查看文档以检查所有可用的函数。
你必须要聪明,想想你正在使用的对象是如何实现的——以及你知道它代表什么的事实。我的意思是——这是标签列表,当每个标签都有不同的类型时——一个是字符串,另一个是 int 等等。你不能轻易地迭代它。
所以我认为你有两个选择——根据你想用标签做什么..
1,序列化为字符串并使用它:
我不确定,但在 C 中有 to_string这可能与 to_string 中的功能相同在 python 中 - 如果您只对标签名称感兴趣,请尝试这样做......或者它返回的任何内容。
2、使用内置foreach及其回调定义:
tags = vinfo.get_tags()
tags.foreach(my_callback, self)
在你的回调中:
def my_callback(list, tag, user_data):
print(tag)
#do whatever you want with list
#not sure how to use casting in python:
YourClass ptr = user_data
ptr.your_method(whatever, tag);
关于Python 类型错误 : 'TagList' object is not iterable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38090102/
我在 Linux 上使用 ctags 和 vim。 一旦我在任何标签上按 Enter,焦点就会转到源代码窗口,为了重新获得标签列表窗口的焦点,我必须执行 :TlistToggle 两次(使用变量 “T
我在 Linux 上使用 ctags 和 vim。 一旦我在任何标签上按 Enter,焦点就会转到源代码窗口,为了重新获得标签列表窗口的焦点,我必须执行 :TlistToggle 两次(使用变量 “T
我在开发中使用 Vim 和 TagList。 TagList 看起来很不错,但是有一个问题是刷新需要很长时间,所以例如我的意思是从同一个文件中的函数 A 到函数 B,TagList 需要大约 5 秒才
我一直在使用 ctags+taglist 一段时间,试图为自己构建一个 IDE。 Taglist 确实做得很好,但在我的 vim 中与缓冲区协作时它偶尔会崩溃。 作为一个新手,我发现我使用插件的方式可
官方tutorial by RStudio关于如何实际使用 tagList() 函数在 Shiny 模块中创建命名空间 ID 有点不清楚。 Shiny documentation也没有多大帮助。我到底
我的 C 代码中的标签列表: macro || MIN_LEN || MAX_ITERATIONS ||- typedef || cell || source_cell ||- variable ||
我用了几天 taglist 插件,现在我用 Javascript 试了一下,但在 Javascript 中它只显示部分信息或没有信息。看来问题可能出在命名空间上,因为函数在 var namespace
这种情况经常发生。一个函数返回一个我无法读取的对象。这里: discoverer = GstPbutils.Discoverer() discoverer.connect('disco
我最近设置了选项 :set relativenumber 在我的 .vimrc ,现在当我打开 Taglist 或 NERDTree 窗口时,这些缓冲区中的行也被编号。 有没有办法禁用 Taglist
我使用 vim 编辑器(在 Ubuntu 上)。最近,我一直在处理大型 cuda 项目,因此想利用 ctags 实用程序进行代码浏览。 exuberant-ctags 支持的语言列表 [这里] (ht
我的 Vim 窗口左侧有 NERDTree(以及中间的主要文件)。每次打开Taglist(:TlistToggle),都会和NerdTree一起显示在左边。 我为 Taglist 做了一个自定义的重映
我试图在 VIM 中安装 Taglist,但我不明白这一步: If the exuberant ctags utility is not present in your PATH, then set
如何在没有鼠标的情况下在 Taglist 栏和当前缓冲区之间切换? 最佳答案 你可以使用 Ctrl-w h/j/k/l 用于在缓冲区之间移动或 Ctrl-w Ctrl-w 遍历所有缓冲区 关于vim
我正在使用 vim 的“taglist”插件来导航我项目中的源文件,但我遇到了一个使用 C++ 文件时特有的问题(与 C 不同;其他语言如 Java 可能会发生这种情况) . 对于文件中的每个函数,它
我无法让 taglist 插件与 Scala 一起正常工作。我已经安装了插件和 ctags 并验证了它可以与 Java 和 C++ 一起正常工作。然后我按照此 page 上的说明进行操作(减去 Lif
基本上,我的 .vimrc开始 TagList和 NERDTree 当 Vim 启动时,在正常文件缓冲区的左侧和右侧拆分。 我想在关闭最后一个缓冲区/选项卡时关闭 Vim,只剩下 TagList 和
我使用带有 ctags 和 Taglist 插件的 Vim。编辑.vhd文件时,标签很差(只显示实体)。 我不知道是否 ctags 对 VHDL 的支持很弱,或者 Taglist 是否在低效地读取 c
我开始在 windows7(64 位)的 gvim 中使用 taglist 插件 这是路径 path of ctags: C:\ctags58 path of gvim: C:\Program Fil
我最近放弃了鼠标驱动的、特定于平台的 GUI 编辑器,并完全致力于 vim。到目前为止的体验非常棒,但我对 Javascript 感到困惑。 广受欢迎的 taglist 实用程序(使用 Exubera
我已经安装了 DoctorJS (以前是 jsctags)试图为 Vim 获得一些好的源代码浏览/标签列表(使用 Taglist 插件)。 安装很顺利,但 Vim 的 Taglist 不适用于 Doc
我是一名优秀的程序员,十分优秀!