自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 day1之python文件

文件

2020-10-20 16:44:15 149

原创 python字符串运用

#大小写str = 'hello,world!dd'str.capitalize #字符串首字母大写str.title #每一个首字母大写str.upper #所有字母大写str.lower #所有字母小写#字符串中的元素处理str.find('') #寻找''内的元素是否在字符串中str.startswith('') #''中的元素是否为开头str.endswith('') #''中的元素是否为结尾str.center(20,'*') #以字符串为中心,左右填充str.rjust(

2020-09-23 09:07:53 110

原创 使用scrapy创建项目时发生错误

1:这时我们需要安装cryptographypip install -I cryptography2:安装时会发生错误,需要更新pip版本,这里使用easy_install pip3:再次安装cryptography,还是无法成功,错误如下:Consider using the --user option or check the permissions.我们需要使用权限,在install 后面加上–userpip install --user -I cryptography...

2020-05-13 15:57:28 688

原创 爬取股票

import requestsfrom bs4 import BeautifulSoupimport tracebackimport redef getHTMLText(url):try:r = requests.get(url, timeout=30)r.raise_for_status()return r.textexcept:return “解析网页出错”def getStockList(lst, stockURL):html = getHTMLText(stockURL)s

2020-05-11 15:48:05 347

原创 爬取中国大学

import requestsfrom bs4 import BeautifulSoupimport bs4def getHtmlText(url):try:r = requests.get(url,timeout=30)r.raise_for_status()r.encoding = r.apparent_encodingreturn r.textexcept:return ...

2020-05-08 14:35:15 104

原创 requests库爬取图片

import requestsimport osurl = ‘’root = ‘D:/aa.jpg’path = root + url.split(’/’)[-1]try:if not os.path.exists(root):os.mkdir(root)if not os.path.exists(path):r = requests.get(url)with open(pat...

2020-05-08 14:33:57 168

原创 爬虫requests库的简单爬取

import requestsr = requests.get(“http://www.baidu.com”) #选取网站r.status_code 检查调取是否正确,为200则正确r.encoding 猜测的响应编码方式r.apparent_encoding 准确的响应编码方式r.content 编码的二进制形式r.headers 头部文件r.text r的内容爬取百度的...

2020-04-30 14:47:49 182

原创 Python的shell中添加清屏功能

1:找到python的idlelib文件,创建一个新的.py文件,文件内容如下2:class ClearWindow:menudefs = [(‘options’, [None,(‘Clear Shell Window’, ‘<>’),]), ]def __init__(self, editwin): self.editwin = editwin self....

2020-04-29 17:07:00 174

原创 Matplotlib:设置坐标轴

import matplotlib.pyplot as pltimport numpy as npx = np.linspace(-3,3,50)y1 = x3y2 = x2+2*x+2#第一个图像plt.figure()plt.plot(x,y1,color=‘red’,linestyle=’–’)#第二个图像plt.figure()plt.plot(x,y1)plt.pl...

2020-04-27 15:57:29 312

原创 python的merge合并

import pandas as pdimport numpy as np1:left = pd.DataFrame({‘key’:[‘k0’,‘k1’,‘k2’,‘k3’],‘A’:[‘a0’,‘a1’,‘a2’,‘a3’],‘B’:[‘b0’,‘b1’,‘b2’,‘b3’]})right = pd.DataFrame({‘key’:[‘k0’,‘k1’,‘k2’,‘k3’],‘C...

2020-04-23 17:03:36 272

原创 python中pandas的几种合并

import pandas as pdimport numpy as np1:上下合并df1 = pd.DataFrame(np.ones((2,4))*0,columns=[‘a’,‘b’,‘c’,‘d’])df2 = pd.DataFrame(np.ones((2,4))*1,columns=[‘a’,‘b’,‘c’,‘d’])#两行四列,每一列分别为abcda b c ...

2020-04-23 15:24:21 383

原创 Array的合并与分割

合并A = np.array([1,1,1])B = np.array([2,2,2])A[:,np.newaxis] #旋转方向B[:,np.newaxis]print(np.vstack((A,B))) #vertical stack 合并(上下合并)print(np.hstack((A,B))) #horizontal 水平合并C = np.concatenate((A,...

2020-04-14 18:24:09 143

原创 关于numpy的基本运算

import numpy as np1:a= np.array([[1,2,3],[2,3,4]])print(a.dtype)查询类型,实现如下:int322:b = np.zeros((3,4))print(b) 实现一个三行四列的元组[[0. 0. 0. 0.][0. 0. 0. 0.][0. 0. 0. 0.]]3:c= np.ones((2,3)) 两行三列的1...

2020-04-10 16:21:28 141

原创 Python之matplotlib基本坐标和legend

import matplotlib.pyplot as pltimport numpy as npx = np.linspace(-3,3,50) #生成50个元素,均匀分布在(-3,3)区间y1 = x*2 + 1y2 = x**2plt.figure()plt.plot(x,y2,color=‘blue’)plt.plot(x,y1,color=‘red’,linewidth...

2020-03-28 15:37:26 425

原创 几个python小问题

1::t.geometry(“260x60+200+250”):制作一个大小为260x60的窗口,距离左上角+200+2502:.grid(row=0,column=0,sticky=“e”)。sticky 意思是组件紧靠所在单元格的某一边角。取值有:“n”, “s”, “w”, “e”, “nw”, “sw”, “se”, “ne”, “center”(默认为” center”)3:t...

2020-03-27 18:30:40 205

原创 tkinter的两个button及LabelFrame

import tkinter as tkwindow = tk.Tk()window.title(‘kobe’)window.geometry(‘400x300’)#将选项放到Label框架里,三个球星group = tk.LabelFrame(window,text=‘最强大的球星’)group.pack()language = [(‘詹姆斯’,1),(‘哈登’,2),(‘科比’...

2020-03-25 15:42:47 862

原创 tkinter之canvas

import tkinter as tkwindow = tk.Tk()window.title(‘画布’)window.geometry(‘200x250’)#创建一个画布canvas = tk.Canvas(window,bg=‘white’,height=200,width=200)image_file = tk.PhotoImage(file=‘ins.gif’) #调用...

2020-03-25 14:55:40 241

原创 关于Entry

的两种表现形式1:import tkinter as tkwindow = tk.Tk()window.title(‘hello welcome’)window.geometry(‘400x300’)#定义四个标签及存放位置l1 = tk.Label(window,text=‘First Name’).grid(row=0)l2 = tk.Label(window,text=‘Las...

2020-03-24 15:38:59 168

原创 tkinter之Scale组件

import tkinter as tkwindow = tk.Tk()window.title(‘测试件’)window.geometry(‘200x200’)s1=tk.Scale(window,from_=0,to=2).pack(side=‘left’)s2=tk.Scale(window,from_=0,to=30,tickinterval=10,resolution=1,...

2020-03-24 14:51:20 159

原创 小计算器py

依据GUI的 一个小计算器import tkinter as tkwindow = tk.Tk()window.title(‘hello welcome’)window.geometry(‘400x300’)def evaluate(event):data = e.get()l2.configure(text=‘answer:’+str(eval(data)))l = tk....

2020-03-24 14:20:33 144

空空如也

空空如也

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

TA关注的人

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