我最近开始学习如何使用python来解析xml文件.我从http://pyxml.sourceforge.net/topics/howto/node12.html获取了教程
当我运行以下代码时,我收到错误:
Traceback (most recent call last):
File "C:\Users\Name\Desktop\pythonxml\tutorials\pythonxml\pyxml sourceforge\5.1 Comic Colection\SearchForComic.py", line 30, in -toplevel-
dh = FindIssue('sandman', '62')
TypeError: __init__() takes exactly 1 argument (3 given)
Run Code Online (Sandbox Code Playgroud)
码:
from xml.sax import saxutils
class FindIssue(saxutils.DefaultHandler):
def __init___(self, title, number):
self.search_title, self.search_number = title, number
def startElement(self, name, attrs):
#if it's not a comic element, ignore it
if name!= 'comic': return
# look for the title and number sttributes (see text)
title = attrs.get('title', None)
number = attrs.get('number', None) …Run Code Online (Sandbox Code Playgroud) 我是Python的新手,试图通过基于"Dive into Python"一书的教程来学习它.我已经在关于SOAP的章节中,当我尝试安装所有必需的库来使用SOAP时,我遇到了一些问题.教程说我需要3个库:
PyXML,fpconst,SOAPpy
我成功安装了fpconst.但是我不能安装另外两个.我在一些论坛上读到要安装SOAPpy我需要安装PyXML,所以问题可能只在第一个库中.
我按照README中的说明操作,但是我遇到了一些错误,我真的不知道出了什么问题,怎么解决它.有关详情,请参见屏幕 我的Python版本是2.7.2+,我正在尝试安装PyXML版本0.8.4.
错误表明此类文件或目录不存在.我正在使用Ubuntu 11.10.
PS:啊!我忘了提到那个.我从这个来源下载了PyXML:
http://sourceforge.net/projects/pyxml/
它写在这里它已经过时了,不应该使用它.那么什么是PyXML的替代品呢?