python 在MySQL中的模糊匹配
2015-11-23 14:57
666 查看
#encoding=utf-8 # 来源:疯狂的蚂蚁的博客总结整理 import jieba import MySQLdb as mdb import sys reload(sys) sys.setdefaultencoding('utf-8') #获取数据库的链接对象 con = mdb.connect('localhost', 'root', '', 'test',charset='utf8') with con: #获取普通的查询cursor cur = con.cursor() cur.execute("SELECT * FROM area where area like '乐清%'") rows = cur.fetchall() #获取连接对象的描述信息 desc = cur.description print 'cur.description:',desc #打印表头,就是字段名字 # print "%s %3s" % (desc[0][0], desc[1][0]) for c1,c2,c3,c4 in rows: #打印结果 seg_list = jieba.cut(c3, cut_all=False) a = ",".join(seg_list)print a
相关文章推荐
- LeetCode OJ 系列之219 Contains Duplicate II --Python
- python的验证码识别.md
- python 的expect,paramiko ssh交互使用
- LeetCode OJ 系列之217 Contains Duplicate --Python
- python 编码问题(转载)
- isalnum()和isalpha()
- 恶补
- python发送邮件
- python 学习小结(1)
- 【Python】django权限管理
- python帮助信息查看以及笔记
- Python基础之【第四篇】
- python codeforces 322 div2 C
- Python问题汇总
- PYTHON之全局变量
- Python如何使用tfidf
- [LeetCode]题解(python):060-Permutation Sequence
- [LeetCode]题解(python):059-Spiral Matrix II
- python 里关于字符的处理
- python 开发中易混淆点