%在python中是个特殊的符号,如%s,%d分别代表了字符串占位符和数字占位符. 大家知道,mysql的模糊查询也需要用到%. 所以,可以先把需要查的字符串抽出来,再以参数方式传入. args = '%'+subtitle+'%' sqlQueryTitle="select count(*) from tbl_peng_article where title like '%s'"%args
python中对两个 list 求交集,并集和差集: 1.首先是较为浅白的做法: >>> a=[1,2,3,4,5,6,7,8,9,10] >>> b=[1,2,3,4,5] >>> intersection=[v for v in a if v in b] >>> intersection [1, 2, 3, 4, 5] >>> union=b.extend([v for v in a]) >>>
一.python中的特殊数据类型 对于python,一切事物都是对象,对象基于类创建.像是“wangming”,38,[11,12,22]均可以视为对象,并且是根据不同的类生成的对象. 参照:http://www.cnblogs.com/wupeiqi/articles/4911365.html 1.列表 如[12,12,23].['wan','fad','dfjap]等 列表具备的功能: class list(object): """ list() -> new em