![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
xiaoxiaoqunqun
github:https://github.com/happydayhappyday
展开
-
使用 PyMySQL 连接数据库,并实现简单的增删改查
首先需要import pymysql1.连接数据库#获取数据库连接def getDBConn(): conn = pymysql.connect( host = 'localhost', port = 3306, user = 'root', password = '123', db = 'insurancedata', charset = 'utf8'...原创 2018-11-21 09:50:50 · 646 阅读 · 0 评论 -
scrapy使用
1.建立工程和Spider模板 scrapy startproject BaiduStockscd BaiduStocksscrapy genspider stocks baidu.com2.运行爬虫scrapy crawl stocks原创 2018-11-21 09:56:28 · 154 阅读 · 0 评论 -
pip install scrapy报错
环境:python3.6.3 error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools ---------------------...原创 2018-11-17 17:17:32 · 183 阅读 · 0 评论 -
python3 对目录下的所有pdf文件重新命名
#!/usr/bin/env python# encoding: utf-8import osdef rename(dirname): filelist = os.listdir(dirname) count = 0 for file in filelist: olddir = os.path.join(dirname,file) if os.path.isdir(oldd...原创 2018-11-26 20:03:02 · 2024 阅读 · 0 评论 -
Python 下载网络文件
# -*- coding: utf-8 -*-import requestsimport csv#下载文件def downloadfiles(url,count): f = requests.get(url) filename = str(count)+".pdf" with open(filename,"wb") as code: code.write(f.content)...原创 2018-11-30 10:15:19 · 1822 阅读 · 0 评论 -
python 从url中提取文件名
import osurl = 'http://www.**.net/images/logo.gif'filename = os.path.basename(url)print(filename)转载 2018-12-03 09:57:54 · 2666 阅读 · 1 评论 -
python 根据文件名删除文件
# -*- coding: utf-8 -*-import osdef delete_file(dirname): filelist = os.listdir(dirname) for file in filelist: oldpath = os.path.join(dirname,file) filename = os.path.splitext(file)[0]#文件名 ...原创 2018-12-08 13:18:40 · 2609 阅读 · 0 评论