python - 输入流错误未定义

发布于 2024-10-30 19:38:34 字数 733 浏览 8 评论 0原文

我正在处理别人的代码,它抛出一个错误,提示“InputStreamError”未定义。我是 python 新手,不确定如何判断 InputStreamError 的定义位置以及如何从代码中引用它。

这就是我目前所得到的:

from hachoir_core.error import HachoirError
from hachoir_core.cmd_line import unicodeFilename
from hachoir_parser import createParser
from hachoir_core.tools import makePrintable
from metadata import extractMetadata
from hachoir_core.i18n import getTerminalCharset
from sys import argv, stderr, exit

def getMetadata(inputFilename):
    filename, realname = unicodeFilename(inputFilename), inputFilename

    try:
        parser = createParser(filename, realname)
    except InputStreamError:
        print "File cannot be found."
        return
    ...

有人对我如何解决这个问题有任何想法吗?

I'm working on someone else's code, and it's throwing an error that 'InputStreamError' is not defined. I'm new to python and am not sure how to tell where InputStreamError is defined and how to reference it from the code.

This is what I've got at the moment:

from hachoir_core.error import HachoirError
from hachoir_core.cmd_line import unicodeFilename
from hachoir_parser import createParser
from hachoir_core.tools import makePrintable
from metadata import extractMetadata
from hachoir_core.i18n import getTerminalCharset
from sys import argv, stderr, exit

def getMetadata(inputFilename):
    filename, realname = unicodeFilename(inputFilename), inputFilename

    try:
        parser = createParser(filename, realname)
    except InputStreamError:
        print "File cannot be found."
        return
    ...

anyone have any ideas on how I could sort this out?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

随心而道 2024-11-06 19:38:34

尝试添加一个

from hachoir_core.stream.input import InputStreamError

Try adding a

from hachoir_core.stream.input import InputStreamError
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文