'unicode' object is not callable
import lxml.html
import urllib
num=1
while(num<=5):
url = "http://www.sdzk.gov.cn/score/gaokao/2010/100804/Book"
final_url = "http://www.sdzk.gov.cn/score/gaokao/2010/100804/Book"+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.gov.cn/score/gaokao/2010/100804/Book"+str(num)+".htm"
except ValueError:
final_url = "http://www.sdzk.gov.cn/score/gaokao/2010/100804/Book"+num+".htm"便出现不能将数字与字符串直接连接的错误了
我该怎么办?希望大家帮帮我(我用的是python 2.5)
...全文
相关推荐
is-unicode-supported:检测终端是否支持Unicode
是unicode支持的 检测终端是否支持Unicode 这对于决定在命令行输出中使用Unicode字符还是回退ASCII字符很有用。 请注意,检查是非常幼稚的。 仅假设所有非Windows终端都支持Unicode和硬代码,而Windows终端确实支持Unicode。 但是,多年来我一直在一些流行的软件包中使用此逻辑,而没有出现问题。 安装 $ npm install is-unicode-supported 用法 const isUnicodeSupported = require ( 'is-unicode-supported' ) ; isUnicodeSupported ( ) ; //=> true 原料药 isUnicodeSupported() 返回有关终端是否支持Unicode的boolean 。 有关的 检查stdout或stderr是否是交互式的 color-检测
Inspect Object (32-bit UNICODE Release)
MS 用于侦测 Accessible 接口的工具
C编码转换:gbk转unicode utf8转unicode
压缩包包括4个函数:gbk转unicode互相转换; utf8和unicode相互转换
实现中文和unicode互相转换的代码
实现 中文 和 unicode 互相 转换 的代码 可以很方便地转换中文和unicode 不用手动到cmd下转换
Unicode字符查询器
一个Unicode码的小程序,可实现字符与Unicode的转换!!!


