python读取路径太长_python – OSError:[Errno 36]文件名太长:

我需要将网页转换为

XML(使用

Python 3.4.3).如果我将URL的内容写入文件,那么我可以完美地阅读和解析它,但如果我尝试直接从网页上读取,我的终端中会出现以下错误:

File “./AnimeXML.py”, line 22, in

xml = ElementTree.parse (xmlData)

File “/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/xml/etree/ElementTree.py”, line 1187, in parse

tree.parse(source, parser)

File “/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/xml/etree/ElementTree.py”, line 587, in parse

source = open(source, “rb”)

OSError: [Errno 36] File name too long:

我的python代码:

# AnimeXML.py

#! /usr/bin/Python

# Import xml parser.

import xml.etree.ElementTree as ElementTree

# XML to parse.

sampleUrl = "http://cdn.animenewsnetwork.com/encyclopedia/api.xml?anime=16989"

# Read the xml as a file.

content = urlopen (sampleUrl)

# XML content is stored here to start working on it.


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部