This topic created in 5650 days ago, the information mentioned may be changed or developed.
def get_city_list(self, site):
city = re.findall(site['city_tag'], self.root, re.S)
if not city:
return false
else:
return city
这个怎么都匹配不到内容
=========================================
def get_city_list(self, site):
a = '<division>(.*?)</division>'
city = re.findall(a, self.root, re.S)
我把上面site['city_tag']内容拿出来,赋值给a
就能匹配到了
====================
说明:site['city_tag'] 是从数据库中取出来的,数据库编码为UTF8
site['city_tag']的内容就是下面定义a的内容
这是为什么呢?编码问题?
type(site['city_tag'])显示是unicode
type(self.root) 也显示的是unicode
为啥就不能匹配到呢?这是为什么呢?
折腾了快一下午了,实在想不明白,请各位高手帮助
1 replies • 1970-01-01 08:00:00 +08:00
 |
|
1
keakon Nov 19, 2010
用logging把site['city_tag']和self.root记录下来,或者直接debug
然后手动运行一遍
代码本身没错,我想应该是数据的问题
话说为什么存储要用XML格式,使用起来非常麻烦
|