随笔分类 -  python

python写入数据库模块(自用)
摘要:from connect_db import DB val = [{"id": 1, "xh": 1001, "name": "a"}, {"id": 2, "xh": 2002, "name": "b"}, {"id": 3, "xh": 3003, "name": "c"}] with DB(db="test") as db: db. 阅读全文
posted @ 2019-10-08 16:11 周围圆 阅读(558) 评论(0) 推荐(0)
python连接mysql数据库(用with关键字)
摘要:#import mysql.connector import pymysql #mydb = mysql.connector.connect( # host = "localhost", # user = "root", # passwd = "123456", # database = "mysql") # #mycu... 阅读全文
posted @ 2019-10-08 16:10 周围圆 阅读(2936) 评论(0) 推荐(1)
write_excel
摘要:# -*- coding: utf-8 -*- """ Created on Wed Sep 18 14:05:24 2019 @author: Administrator """ import os import traceback #import openpyxl import xlrd import xlwt from xlutils.copy import copy # # # 操作.xl 阅读全文
posted @ 2019-09-20 15:59 周围圆 阅读(560) 评论(0) 推荐(0)
程序 request_xkz
摘要:# -*- coding: utf-8 -*- """ Created on Mon Sep 9 10:07:50 2019 @author: Administrator """ import os import re import traceback import requests import openpyxl from bs4 import BeautifulSoup #from write 阅读全文
posted @ 2019-09-20 15:59 周围圆 阅读(152) 评论(0) 推荐(0)
python中map、reduce、filter函数的简单使用
摘要:from functools import reduce # map函数,可以将一个列表内的元素代入指定的函数内,运算后生成一个新的列表 # 实现批量操作功能 list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9] def f1(x): return x**2 def f2(x): return x + 1 def f3(x): return x - 1 def map_test( 阅读全文
posted @ 2019-09-20 14:00 周围圆 阅读(298) 评论(0) 推荐(0)
python下openpyxl和xlrd、xlwt、xutils.copy的简单使用(自测)
摘要:# -*- coding: utf-8 -*- """ Created on Wed Sep 18 14:05:24 2019 @author: Administrator """ import os import traceback import openpyxl import xlrd import xlwt from xlutils.copy import copy # 操作.xlsx格式e 阅读全文
posted @ 2019-09-19 17:25 周围圆 阅读(1364) 评论(0) 推荐(0)
python bs4+requests 实现大学排名爬取
摘要:# -*- coding: utf-8 -*- """ Created on Mon Sep 9 10:55:55 2019 @author: Administrator """ import os import requests import bs4 from bs4 import BeautifulSoup def main(): url = "http://www.zuihaodaxue.c 阅读全文
posted @ 2019-09-16 09:19 周围圆 阅读(358) 评论(0) 推荐(0)
python-openpyxl的简单应用
摘要:import openpyxl # 读 def read16excel(path): # 实例化excel表 wb = openpyxl.load_workbook(path) # 创建新工作表 wb.create_sheet("Sheet2") # 查看sheet页名字 print(wb.sheetnames) # 通过索引定位sheet页 sheet = wb.worksheets[0] # 阅读全文
posted @ 2019-09-15 14:21 周围圆 阅读(421) 评论(0) 推荐(0)