Simple Use of Locator Object Methods,locatormethods,import sysfr
Simple Use of Locator Object Methods,locatormethods,import sysfr
import sysfrom xml.sax import saxutilsfrom xml.sax import make_parserfrom xml.sax import handlerclass SimpleHandler(saxutils.DefaultHandler): # Obtain a locator object def setDocumentLocator(self,locator): self.locator = locator def startElement(self,name,attrs): col = self.locator.getColumnNumber() line = self.locator.getLineNumber() pubid = self.locator.getPublicId() sysid = self.locator.getSystemId() print 'startElement (%d,%d,%s,%s): %s' % (line,col,pubid,sysid,name) def endElement(self,name): col = self.locator.getColumnNumber() line = self.locator.getLineNumber() pubid = self.locator.getPublicId() sysid = self.locator.getSystemId() print 'endElement (%d,%d,%s,%s): %s' % (line,col,pubid,sysid,name) def characters(self,data): print 'characters: ', repr(data)parser = make_parser()sh = SimpleHandler()parser.setContentHandler(sh)parser.parse(sys.argv[1])
- List append(x),listappend,# Add an
- And or with values in a list,valueslist,t, f = 1, 0x
- If it has a certain key,hascertain,D = {'a': 1,
- Fix Python script(s) to reference the interpreter via /u
- Re design the intersect and union using tuple parameter
- Function parameters: using the double asterisk operator,
热门文章:
相关内容
- List append(x),listappend,# Add an
- And or with values in a list,valueslist,t, f = 1, 0x
- If it has a certain key,hascertain,D = {'a': 1,
- Fix Python script(s) to reference the interpreter via /usr/bin/env py
- Re design the intersect and union using tuple parameter passing,int
- Function parameters: using the double asterisk operator,asteriskope
- String method: to a title,stringmethod,quote = 'Pyt
- Using the break statement to avoid repeating code in the class-averag
- Mouse action: double click,mousedouble,from Tkinter
- Power function,powerfunction,def power(x,
评论关闭