'unicode' object is not callable
程序代码:
import lxml.html import urllib num=1 while(num<=5): url = "http://www.sdzk." final_url = "http://www.sdzk."+str(num)+".htm" page = urllib.urlopen(final_url) str = page.read().decode("gb2312") doc = lxml.html.fromstring(str) name_ele = doc.cssselect("td") i = 26 plan = 0 post = 0 while(i<len(name_ele)): if((i-26)%11==0): try: plan = int(name_ele[i+6].text) post = int(name_ele[i+8].text) print "%s,%d" % (name_ele[i].text,plan-post) except TypeError: print "None" i = i+1 num = num+1
大家好,我写的这个程序最外面的循环第一次循环时没问题,第二次循环时便出现如下错误:
(第七行)TypeError: 'unicode' object is not callable
我不明白哪个是'unicode' object?
我改为
try: final_url = "http://www.sdzk."+str(num)+".htm" except ValueError: final_url = "http://www.sdzk."+num+".htm"便出现不能将数字与字符串直接连接的错误了
我该怎么办?希望大家帮帮我(我用的是python 2.5)