图形解析错误
我尝试使用 python 和 igraph 库创建 graphml 文件。我可以构造 igraph 的图形对象并将其写入文件,使用:
g.write_graphml("mygraph.graphml")
一切似乎都很成功,但是当我尝试使用以下方法将文件读回 python 时:
g = Graph.Read_GraphML('mygraph.graphml')
我收到此错误:
igraph.core.InternalError: Error at .\src\foreign-graphml.c:1024:
Input is not proper UTF-8, indicate encoding ! Bytes: 0xA0 0x3C 0x2F 0x64
请问如何解决这个问题? 非常感谢。
I tried to create a graphml file using python and igraph library. I can construct igraph's graph object and wrote it to a file using:
g.write_graphml("mygraph.graphml")
Everything seems to be successful but when I tried to read the file back to python using:
g = Graph.Read_GraphML('mygraph.graphml')
I got this error:
igraph.core.InternalError: Error at .\src\foreign-graphml.c:1024:
Input is not proper UTF-8, indicate encoding ! Bytes: 0xA0 0x3C 0x2F 0x64
How can I solve this, please?
Thank you very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经看到了库源代码。我认为库只能输出 UTF-8 XML 编码。因此所有字符都必须是 UTF-8 编码,如果文件中包含某些非 UTF-8 字符,则会引发错误。
解决方案:
您应该在使用之前将 python 应用程序中的所有字符串转换为 UTF-8 编码,如此处
所述希望有所帮助。
I already see the libary source code. I think library can output only UTF-8 XML Encoding. So all character must be UTF-8 encoding and if some non-UTF-8 character contains in file, Errors will be raised.
The Solution:
You should convert all string in your python application to UTF-8 encoding before use as describe here
Hope this help.
我认为问题应该来自 Unicode 无效字节序列问题,但没有你的文件我只能猜测。
我认为您可以从非 Unicode 编码文件加载字符串并直接使用它,而无需转换为 Unicode 编码。请尝试通过查看这篇文章将这些字符串转换为 Unicode。
一只忙碌的猫 http://goo.gl/CFGYf
I think problem should come from Unicode invalid bytes sequence problem but without your file I can only guess.
I think you may load string from non-Unicode encoding file and use it directly without convert to Unicode encoding. Please try convert these strings to Unicode by see this post.
a busy cat http://goo.gl/CFGYf