python-3.x - Python - gphoto2 如何弄清楚函数的作用?
问题描述
我正在玩 gphoto2,发现该camera
对象具有公共功能file_get_info()
。我想知道:
- 这个函数是做什么的
- 怎么称呼它
但到目前为止,我还没有找到任何有关它的信息。
这就是我所做的:
import gphoto2 as gp
portInfoList = gp.PortInfoList()
portInfoList.load()
abilitiesList = gp.CameraAbilitiesList()
abilitiesList.load()
cams = abilitiesList.detect(portInfoList)
for name, addr in cams:
print("%s at port %s"%(name, addr))
idx = portInfoList.lookup_path(addr)
camera = gp.Camera()
camera.set_port_info(portInfoList[idx])
camera.init()
camera.file_get_info()
这就是我得到的:
TypeError: Camera_file_get_info expected at least 2 arguments, got 0
更令人沮丧的是,无论我多么努力地谷歌,我都找不到有关该Camera_file_get_info
功能的任何信息。
我接近这个错误吗?
解决方案
对象上的file_get_info
方法Camera
是 libgphoto2 函数的 Pythonic 版本gp_camera_file_get_info
。这将是一个更好的网络搜索术语。
有几种方法可以获取您正在寻找的信息。像其他 Python 模块一样,您可以使用 pydoc:
pydoc3 gphoto2.Camera.file_get_info
Help on method_descriptor in gphoto2.Camera:
gphoto2.Camera.file_get_info = file_get_info(...)
file_get_info(char const * folder, char const * file, Context context)
Retrieves information about a file.
Parameters
----------
* `camera` :
a Camera
* `folder` :
a folder
* `file` :
the name of the file
* `info` :
* `context` :
a GPContext
Returns
-------
a gphoto2 error code
See also gphoto2.gp_camera_file_get_info
这取自“C”文档,因此参数列表有点混乱 -info
在 C 版本中是一个参数,但在 Python 中不是。您需要的两个参数是folder
和file
- 这些参数告诉函数您想要有关哪个文件的信息。
您可能更喜欢直接使用 C 文档:http ://www.gphoto.org/doc/api/gphoto2-camera_8h.html#adda54321b1947b711d345936041f80c7这包括info
结构的链接。
最后,list-files.py
包含的示例程序python-gphoto2
显示了file_get_info
.
推荐阅读
- javascript - 更新后如何刷新amChart的图例并防止图例重复
- json - 如何将多部分请求中的图像文件作为 http 正文参数(POST)传递
- java - 我的 android 应用程序占用大量内存并停止响应
- javascript - 使用 JavaScript 在新选项卡中提交表单
- python - 是否可以创建 mediapipe 的身体姿势标志和连接的情节动画 3D 散点图?
- r - 从另一个数据框映射后获取笛卡尔积
- go - 有没有办法更新 go 包并忽略错误?
- jenkins - Jenkins Gitlab 多分支并发构建
- ios - 如何从 iTunes Connect 或 AppStore Connect 下载应用程序评论和评级
- java - Selenium Java 处理不同语言和位置以及设置动态架构的最佳实践?