2012年12月24日

Python中MySQLdb的各种常见用法

摘要: Python代码#-*-coding:utf-8-*-#mysqldbimporttime,MySQLdb#连接conn=MySQLdb.connect(host="localhost",user="root",passwd="",db="test",charset="utf8")cursor=conn.cursor()#写入sql="insertintouser(name,created)values(%s,%s)"param=("aaa",int(ti 阅读全文

posted @ 2012-12-24 16:17 linzuxin 阅读(372) 评论(0) 推荐(0) 编辑

Python中urllib2总结

摘要: 使用Python访问网页主要有三种方式: urllib, urllib2, httpliburllib比较简单,功能相对也比较弱,httplib简单强大,但好像不支持session1. 最简单的页面访问res=urllib2.urlopen(url)print res.read()2. 加上要get或post的数据data={"name":"hank", "passwd":"hjz"}urllib2.urlopen(url, urllib.urlencode(data))3. 加上http头header={&quo 阅读全文

posted @ 2012-12-24 10:35 linzuxin 阅读(253) 评论(0) 推荐(0) 编辑

导航