擅长:python、mysql、java
<pre><code>class ListParser:
def __init__(self, s):
self.str = s.split("\n")
print self.str
self.answer = []
def parse(self):
self.nextLine()
self.topList()
return
def topList(self):
while(len(self.str) > 0):
self.topListItem()
def topListItem(self):
l = self.nextLine()
print "TOP: " + l
l = self.nextLine()
if l != '':
raise Exception("expected blank line but found '%s'" % l)
sub = self.sublist()
def nextLine(self):
return self.str.pop(0)
def sublist(self):
while True:
l = self.nextLine()
if l == '':
return # end of sublist marked by blank line
else:
print "SUB: " + l
parser = ListParser(s)
parser.parse()
print "done"
</code></pre>
<p>印刷品</p>
^{pr2}$