随笔分类 -  python

学习记录
import re
摘要:import re # 使用match()方法进行匹配 pattern = r'mr_\w+' #模式字符串 string = 'MR_SHOP mr_shop' match = re.match(pattern,string,re.I) print(match) string = '项目名称MR_ 阅读全文

posted @ 2020-07-27 16:39 winecork 阅读(229) 评论(0) 推荐(0)

信息的组织和提取方法
摘要:XML:eXtensible Markup Language <name>...</name> <name /> <!-- --> JSON:JavaScript Object Notation "key":"value" "key":["value1","value2"] "key":{"subk 阅读全文

posted @ 2020-02-28 18:01 winecork 阅读(278) 评论(0) 推荐(0)

BeautifulSoup
摘要:BeautifulSoup解析器 解析器 使用方法 条件 bs4的HTML解析器 BeautifulSoup(mk,'html.parser') 安装bs库 lxml的HTML解析器 BeautifulSoup(mk,'lxml') pip install lxml lxml的xml解析器 Beau 阅读全文

posted @ 2020-02-26 00:23 winecork 阅读(208) 评论(0) 推荐(0)

requests模块学习
摘要:import requests url = 'https://item.jd.com/2967929.html' try: r = requests.get(url) r.raise_for_status() r.encoding = r.apparent_encoding print(r.text 阅读全文

posted @ 2020-02-25 04:08 winecork 阅读(167) 评论(0) 推荐(0)

修改类的属性值
摘要:#直接修改属性的值# -*- coding:utf-8 -*- class Car(): def __init__(self,make,model,year): self.make = make self.model = model self.year = year self.odometer_re 阅读全文

posted @ 2020-01-29 00:17 winecork 阅读(395) 评论(0) 推荐(0)

值传递和引用传递
摘要:根据实际参数的类型不同,可以将实际参数的值传递给形式参数,或将实际参数的引用传递给形式参数。 其中,当实际参数为不可变对象时,进行的时值传递;当实际参数为可变对象时,进行的时引用传递。 值传递和引用传递区别: 值传递后,改变形式参数的值,实际参数的值不变; 引用传递后,改变行是参数的值,实际参数的值 阅读全文

posted @ 2019-12-02 23:15 winecork 阅读(153) 评论(0) 推荐(0)

python正则表达式
摘要:常用元字符 代码 说明 . 匹配除换行外的任意字符 \w 匹配字母、数字、下划线、汉字 \s 匹配任意的空白符 \d 匹配数字 \b 匹配单词的开始或结束 ^ 匹配字符串的开始 $ 匹配字符串的结束 常用限定符 限定符 说明 举例 ? 匹配前面的字符0次或1次 colou?r,可以匹配colour和 阅读全文

posted @ 2019-12-01 23:34 winecork 阅读(154) 评论(0) 推荐(0)

pyperclip模块
摘要:安装pyperclip模块 pip install pyperclip 导入pyperclip模块后,复制文本“hello world”,打印现在剪切板上的内容“hello world” 阅读全文

posted @ 2019-11-02 16:48 winecork 阅读(214) 评论(0) 推荐(0)

python画国旗
摘要:import turtle def draw_rectangle(start_x,start_y,rec_x,rec_y): turtle.goto(start_x,start_y) turtle.color('red') turtle.fillcolor('red') turtle.begin_f 阅读全文

posted @ 2019-11-01 11:27 winecork 阅读(1079) 评论(0) 推荐(0)

mapIt.py
摘要:不打开浏览器,直接加载搜索关键的网站 安装模块 pip install webbrowser pip install pyperclip 文件:mapIt.py 阅读全文

posted @ 2019-04-22 23:09 winecork 阅读(104) 评论(0) 推荐(0)

pygame安装及测试
摘要:pip install pygame python -m pygame.examples.aliens 阅读全文

posted @ 2019-04-15 16:16 winecork 阅读(302) 评论(0) 推荐(0)

WordCloud
摘要:文本1.txt + 图9.jpg 9.jpg 1.jpg 阅读全文

posted @ 2019-04-09 10:59 winecork 阅读(130) 评论(0) 推荐(0)

python写入xls
摘要:安装xlwt windows,cmd,pip install xlwt 读取linux下的cat /proc/cpuinfo>cpuinfo 代码: 文件cpuinfo 阅读全文

posted @ 2019-04-04 13:56 winecork 阅读(129) 评论(0) 推荐(0)

使用pip安装matplotlib
摘要:失败: >python -m pip install --user matplotlib.whl #本地安装失败 >pip install matplotlib #超时 成功: pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some- 阅读全文

posted @ 2019-02-21 16:20 winecork 阅读(443) 评论(0) 推荐(0)

进度条
摘要:import sys,time for i in range(20): sys.stdout.write("#") sys.stdout.flush() time.sleep(0.1) 阅读全文

posted @ 2017-11-16 18:51 winecork 阅读(71) 评论(0) 推荐(0)

maketrans与translate函数
摘要:ccbba 阅读全文

posted @ 2017-09-19 16:54 winecork 阅读(124) 评论(0) 推荐(0)

pycharm主题设置
摘要:File>Settings: Appearance & Behavior>Appearance>Theme:Darcula Editor>Color & Fonts>Python>Scheme:Darcula 阅读全文

posted @ 2017-08-27 22:18 winecork 阅读(116) 评论(0) 推荐(0)

导航