python -- 网络和数据库
来源:互联网 发布:金山软件安全卫士 编辑:程序博客网 时间:2024/06/01 09:19
网络
import urllib.request as reqpath = "http://www.baidu.com/"res = req.urlopen(path)help(res)bytes = res.read() #获取字节流html = bytes.decode("UTF-8") #转码with open("./file1.html", "bw") as f: f.write(bytes)
数据库
import pymysql as pmconn = pm.connect(host="localhost", user="xxx", password="xxx", database="xxx")cursor = conn.cursor()rows = cursor.execute("select * from xxx")for i in range(rows): one = cursor.fetchone()#获取游标所在第一行数据 #print(one[0], one[1])cursor.close()conn.close()#参数化查询,防止SQL注入cursor.mogrify("select a,b from xxx where user=%s and pass=%s",(user,passwd))####################effect_rows = cursor.execute(“select * from user”)effect_row = cursor.execute("update test set pass = '123' where nid = %s", (11,'stu'))effect_row = cursor.executemany("insert into test(user,pass,licnese)values(%s,%s,%s)",[("u1","u1pass","11111"),("u2","u2pass","22222")])
阅读全文
0 0
- python -- 网络和数据库
- 《网络爬虫-Python和数据分析》数据库建库建表问题
- Python网络爬虫-CetOS7环境MySQL数据库安装和配置
- python----文件、数据库、网络编程
- Python网络爬虫与数据库
- python基本知识、数据库、网络、编程等总结
- Python的并发和网络
- 关于与本地数据库和网络数据库
- MySQLdb和Python数据库操作
- Python之队列和数据库
- 10gocm->session1->数据库和网络配置
- 宝典——操作系统、数据库和网络
- 项目开发之网络连接和数据库
- 缓存网络数据--Rx和数据库
- 网络请求 、二级列表和数据库
- Java学习--网络,图形界面和数据库
- Python网络页面抓取和页面分析
- Python基础 4----文件和网络
- 单例模式——静态内部类式
- Docker安装步骤
- python -- 文件和IO操作
- CF500B New Year Permutation (贪心+并查集)
- Android 以apk包方式共享资源(动态换肤)的实现方式
- python -- 网络和数据库
- 多因子模型之因子(信号)测试平台----alphalens(四)
- python -- 面向对象编程
- CSS3按钮动画
- 《Angular2入门系列基础》——ActivatedRoute路由
- leetcode 25. Reverse Nodes in k-Group
- 编程练习
- CSS的单位及css3的calc()及line-height百分比
- 机器学习算法小整理之K-means