自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(23)
  • 收藏
  • 关注

原创 Python实战笔记-常用知识点

一、个人自学Python的最终的目标是a,实现自动化办公b,实现数据的爬取c,实现基本的数据分析(SEMMA)S:Sample(收集数据)常用手段:问卷调查,数据库查询,实验室实验,仪器设备的记录E:Explore(数据探索)探索方向:离散变量的分布比例,连续变量的分布形态,数据的异常和缺失,特征选择M:Modify(数据修正)常用修正方法:数据类型的转换,数据的一致性处理,异常值和缺失值的处理,数据形态的转换M:Model(数据建模)常用的模型:有监督的预测性模型(如回归、决策树、K

2020-10-07 09:10:33 233

原创 Python实战笔记-Lock版生产者和消费者模式4

import threadingimport randomgMoney = 0gLock = threading.Lock()class Producer(threading.Thread): def run(self) -> None: global gMoney while True: gLock.acquire() money = random.randint(0,100)

2020-12-07 10:11:10 129 1

原创 Python实战笔记-多线程全局变量3

import threadingvalue = 0gLock = threading.Lock() # 在需要修改全局变量的地方才需要加锁def add_value(): # 如果在函数中修改了全局变量,那么需要使用 # global冠军字进行申明 global value gLock.acquire() # 加锁 for x in range(10000000): value +=1 gLock.release() # 释放

2020-12-07 10:10:26 105

原创 Python实战笔记-创建多线程类2

import timeimport threading## def coding():# the_thread = threading.current_thread()# print(the_thread.name)# for x in range(3):# print("%s正在写代码..." % the_thread.name)# time.sleep(1)### def drawing():# the_threa

2020-12-07 10:09:31 89

原创 Python实战笔记-threading基本使用1

import timeimport threadingdef coding(): for x in range(3): print("%d正在写代码..."%x) time.sleep(1)def drawing(): for x in range(3): print("%d正在画图..." % x) time.sleep(1)# def single_thread():# coding()#

2020-12-07 10:08:37 73

原创 Python实战笔记-load成Python对象

import jsonjson_str = '[{"name": "三国演义", "price": 18.8}, {"name": "水浒传", "price": 19.8}]'# print(type(json_str))# result = json.loads(json_str)# print(result)# print(type(result))with open("books.json",'r',encoding='utf-8') as fp: result = js

2020-12-07 10:06:58 104

原创 Python实战笔记-dump成json字符串

import jsonbooks = [ { "name":"三国演义", "price":18.8 },{ "name": "水浒传", "price":19.8 }]# result = json.dumps(books,ensure_ascii=False)# print(result)# print(type(result))fp = open("books.json",'w',encodin

2020-12-07 10:06:14 71

原创 Python实战笔记-excel相关库2

pip install xlrd 用于读一个excel中有多个sheet,那么可以通过以下方法来获取想要的sheet信息:sheet_names 获取所有sheet的名字sheet_by_index 根据索引获取sheet对象sheeet_by_name 根据名字获取sheet对象sheets 所有sheet对象sheet.nrows 行数sheet.ncols 列数获取cell相关操作:sheet.cell(row,col) 指定行和列sheet.row_sl

2020-12-03 11:22:42 131

原创 Python实战笔记-excel读取1

import xlrdworkbook = xlrd.open_workbook("成绩表.xlsx")#获取所有的sheet名字# print(workbook.sheet_names())# 根据索引获取指定的sheet对象sheet = workbook.sheet_by_index(1)print(sheet.name)

2020-12-03 11:19:52 79

原创 Python实战笔记-csv文件写入2

import csvheaders = (‘name’,‘age’,‘height’)# students =[# ("张三",18,180),# ("李四",19,190),# ("王五",20,170)# ]students =[{“name”:“张三”,“age”:18,“height”:180},{“name”:“李四”,“age”:19,“height”:190},{“neme”:“王五”,“age”:20,“height”:170},{“neme”

2020-12-03 11:18:07 89

原创 Python实战笔记-csv文件读取1

import csv# with open("stock.csv",'r',encoding='utf-8') as fp: #gbk解码# reader = csv.reader(fp)# for x in reader:# print(x[3])with open(“stock.csv”,‘r’,encoding=‘utf-8’) as fp: #gbk解码reader = csv.DictReader(fp)for x in reader:pr

2020-12-03 11:17:16 171

原创 Python实战笔记-更新数据6

import pymysqldb = pymysql.connect(host=“127.0.0.1”,user=‘root’,password=‘11111111’,database=“pymysql_test”,port=3306,charset=‘utf8’)cursor = db.cursor()sql= “update article set title=‘钢铁是怎样炼成的’ where id=3”cursor.execute(sql)db.commit()db.clos

2020-12-03 11:01:55 56

原创 Python实战笔记-删除数据5

import pymysqldb = pymysql.connect(host=“127.0.0.1”,user=‘root’,password=‘11111111’,database=“pymysql_test”,port=3306)cursor = db.cursor()sql = “delete from article where id=2”cursor.execute(sql)db.commit()db.close()

2020-12-03 11:01:15 93

原创 Python实战笔记-查找数据4

import pymysqldb = pymysql.connect(host=“127.0.0.1”,user=‘root’,password=‘11111111’,database=“pymysql_test”,port=3306)cursor = db.cursor()sql = “select id,title from article where id>3”cursor.execute(sql)result = cursor.fetchone()result = cu

2020-12-03 11:00:40 60

原创 Python实战笔记-插入数据库3

import pymysqldb = pymysql.connect(host=“127.0.0.1”,user=‘root’,password=‘11111111’,database=“pymysql_test”,port=3306)cursor = db.cursor()sql = “insert into article(id,title,content) values(null,‘222’,‘333’)”cursor.execute(sql)title = ‘555’cont

2020-12-03 10:59:53 110

原创 Python实战笔记-连接数据库2

import pymysqldb = pymysql.connect(host=“127.0.0.1”,user=‘root’,password=‘11111111’,database=“pymysql_test”,port=3306)cursor = db.cursor()cursor.execute(“select * from article”)result = cursor.fetchone() # 提取第一条数据print(result)...

2020-12-03 10:58:38 63

原创 Python实战笔记-数据库笔记1

知识点1 Python连接MYSQL‘’’连接MYSQL示例:import pymysqldb = pymysql.connect(host=“127.0.0.1”,user=‘root’,password=‘root’,database=‘pymysql_test’,prot=3306)cursor = db.cursor()cursor.execute(“select1”)data = cursor.fetchone()print(data)db.close()‘’’知识点2 插入

2020-12-03 10:57:08 1131 8

原创 Python实战笔记-遍历多个列表生成列表或字典

1、生成字典key=['a','b','c','d']value=[1,2,3,4]mydict=dict(zip(key,value))print mydict#输出:{'a': 1, 'c': 3, 'b': 2, 'd': 4}2、也可以用zip同时遍历多个列表,生成一个多维列表key=['a','b','c','d']value=[1,2,3,4]other=[5,6,7,8]print map(list,zip(key,value,other))#输出:[['a', 1

2020-10-30 19:02:21 396

Python实战笔记-论文网站的搭建

构建思路:1、数据来源arxiv.org/list/cs/pastweek2、后端API的构建Flask,是python中知名的web框架,可通过其快速构建网站的后端API3、前端界面的构建Bootstrap,让web开发更迅捷4、上线到服务器gunicorn 作为上线到服务器...

2020-10-19 11:33:53 118

Python实战笔记-数据分析-Pandas

Pandas模块核心:1、外部数据的读取;2、认知数据点额概览信息;3、数据子集到筛选与清洗;4、数据的汇总处理;5、数据的合并与连接;

2020-10-18 20:23:18 93

原创 Python实战笔记-数据分析-Numpy

Numpy模块:使运用高效、代码简洁核心:一、数组的构造及其优势;二、常用的数学函数与统计函数;一、数组的构造及其优势A、数组的构造 (一维数组)背景:列表只是一种数据的存储容器,它不具有任何计算能力!#身高height = [176,168,163,177,172,169]#体重weight = [82,98,102,126,99,88]#BMI指数(身高质量指数=体重(Kg)/身高(m)的平方)BMI = weight / (height/100)**2#解决方案(将两个列表

2020-10-08 13:27:59 228

原创 Python实战笔记-网络爬虫

网络爬虫定义:按照一定的规则,自动的抓取网站信息的脚本。典型的应用:搜索引擎、今日头条、竞品分析等

2020-10-08 00:12:06 174

原创 MAC环境中的PHP+Mysql连接

一、MAC自带Apache,那么我们只需要考虑开启,关闭,重启:a,开启Apache命令:sudo apachectl startb,关闭Apache命令:sudo apchectl stopc,重启Apache命令:sudo apchectl restart二、设置站点(mac用户必须放在user/…用户下)a,在bash终端中cd /etc/apche2b,备份httpd.conf 为 httpd.conf.bak ,操作命令为:sudo cp httpd.conf httpd.conf

2020-09-28 12:15:37 356

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除