Python
豌豆射手GCC
这个作者很懒,什么都没留下…
展开
-
Project:10 SuperGeocoder
SuperGeocoder在web上完成CSV格式文件的上传;为含有Address属性的CSV格式文件添加经纬度属性;在web上显示该dataframe:data.to_html()script.py:建立一个文件夹用于存储更改后的csv文件;文件命名需引入datetime,加入当前时间方式名称重复;from flask import Flask,render_template,request,send_file #得到email by request#from werkze原创 2020-06-19 00:57:22 · 149 阅读 · 0 评论 -
Flask:web中添加 upload file and download file 功能
在form表单中添加file; <form action={{url_for('download')}} method='POST' enctype="multipart/form-data"> <input type="file" name='file'> <br> <button type="submit">Submit</button>原创 2020-06-18 14:52:39 · 351 阅读 · 0 评论 -
Project9:Data collector web (backend)
BackEnd搭建flask环境_cmd虚拟环境;pip install virtualenv建立virtual文件夹(内含虚拟python);py -3 -m venv virtual方法2:进入虚拟python的cmd:virtual/Scripts/activate搭建Flask框架_pythonapp.py注意success,methods=[“POST”]解释:__name__得到当前py的名字——— __ main __ ;Flask()为flask的构造函数;原创 2020-06-17 23:40:53 · 233 阅读 · 0 评论 -
Project9:Data collector web(frontend)
FrontendHTMLcodeindex.htmlform表单,构建两个输入+一个button按钮;<!DOCTYPE html><html lang="en"> <title>Data Collector App</title> <head> <link href="../static/main.css" rel="stylesheet"> </head> <原创 2020-06-16 21:05:09 · 109 阅读 · 0 评论 -
Project8: CandlestickChart+embed in Web
利用bokeh搭建的HTML图片——candlestckchart的代码import requestsfrom pandas_datareader import dataimport datetimefrom bokeh.plotting import figure,show,output_filefrom bokeh.embed import components #embedfrom bokeh.resources import CDN #content delivery network原创 2020-06-16 16:19:55 · 213 阅读 · 1 评论 -
pandas_datareader+bokeh Stock_analysis
Stock_analysis使用data.DataReader(name=,data_source=,start,end)对stock数据进行爬取;此时df存入apple股票的数据,从2016.3.1到2016.3.10;import requestsfrom pandas_datareader import dataimport datetimefrom bokeh.plotting import figure,show,output_filestart=datetime.datetime原创 2020-06-16 00:34:41 · 286 阅读 · 0 评论 -
爬取豆瓣评论+url翻页
爬取豆瓣评论BeautifulSoup得到网页信息;get_url进行翻页操作;jieba进行单词分割;wordcloud进行词云处理;matplotlib进行图形绘制;from bs4 import BeautifulSoupimport requestsimport pandasdef get_url(n): url="https://music.douban.com/subject/35093585/comments/hot?p=" url=url+str(n)原创 2020-06-15 15:21:55 · 1046 阅读 · 0 评论 -
Program7:WebScraping
读入网站import requestsfrom bs4 import BeautifulSoupr=requests.get("http://www.pyclass.com/real-estate/rock-springs-wy/LCWYROCKSPRINGS/",headers={"User-agent":'Mozilla/5.0(X11;Ubuntu;Linux x86_64;rv:61.0)Gecko/20100101 Firefox/61.0'})soup=BeautifulSoup(r.c原创 2020-06-15 14:53:15 · 161 阅读 · 0 评论 -
爬虫+词云——Bilibili弹幕 (chardet处理html+matplotlib.pyplot绘图)
Python爬取弹幕在bilibili得到需要爬取的视频的弹幕地址;https://api.bilibili.com/x/v1/dm/list.so?oid=201056987 #得到bilibili弹幕地址http://api.bilibili.com/x/player/pagelist?bvid=BV1PK4y1b7dt&jsonp=jsonp #得到视频的oid——cidhttps://www.bilibili.com/video/BV1PK4y1b7dt?t=1 #此为视频的地址原创 2020-06-14 17:01:59 · 564 阅读 · 0 评论 -
Requests+BeautifulSoup+python Basic WebScraping
标题引入头文件import requestsfrom bs4 import BeautifulSoupc保存requests.get得到的网站的html代码;r=requests.get("http://www.pyclass.com/example.html",headers={"User-agent":'Mozilla/5.0(X11;Ubuntu;Linux x86_64;rv:61.0)Gecko/20100101 Firefox/61.0'}) #getc=r.contents原创 2020-06-14 15:50:02 · 101 阅读 · 0 评论 -
Project6: OpenCV+Bokeh+Pandas Motion Detector
将Motion Detector得到的Numpyarray处理成Bokeh图像from capture import df #运行ploting 会运行capturefrom bokeh.plotting import figure,show,output_filep=figure(x_axis_type="datetime",height=100,width=500,sizing_mode="scale_both",title="Motion Graph")q=p.quad(l原创 2020-06-14 00:24:23 · 183 阅读 · 0 评论 -
Bokeh Graph
利用 Bokeh+数组 建图导入figurefrom bokeh.plotting import figure 用于绘图;导入output_filefrom bokeh.io import output_file 用于输出html图片;导入showfrom bokeh.io import show 用于输出图片;output_file(“图片名称.html”);f=figure() 创建figure;f.line(x,y) 传入x数组,y数组,绘制线型图(rectangle 方块点,circl原创 2020-06-13 23:44:39 · 183 阅读 · 0 评论 -
Webcam Motion Detector
实现对视频的动态捕捉video=cv2.VideoCapture(0) 实现对摄像头的控制;video.read() 得到摄像头打开后的第一帧图像,存入frame;gray得到灰度图;gaussianBlur进行高斯模糊;若是第一张图,则保存为first_frame;后续图与第一张图比较,cv2.absdiff(first_frame,gray);黑白+扩大;黑白:absdiff得到的30以内的像素点为黑色,其余为白色;并进行dilate扩大,参数如下;thresh_frame=cv2.原创 2020-06-13 18:44:54 · 442 阅读 · 0 评论 -
OpenCv+cascade 进行图像识别——python
1.传入XML文件建立模型import cv2face_cascade=cv2.CascadeClassifier("haarcascade_frontalface_default.xml")2.载入图片传入为BGR图,转为Grey图后进行识别;#识别模型img = cv2.imread("photo.jpg") #不传入参数 默认1grey_img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) #将BGR转为gray#cascade XML m原创 2020-06-11 16:12:24 · 657 阅读 · 0 评论 -
OpenCV_python
导入图片cv.imread(图片路径,0=灰度 1=tgb);得到图片的像素numpy矩阵;import cv2img =cv2.imread("galaxy.jpg",0) #选则1 rgb or 0 灰度 -1color image(含有transparancy)#numpy 类型 #灰度0 为二维numpy 代表每个像素的灰度设置图片大小cv2.resize(图片矩阵,(宽,高));可调用img.shape,【0】为高,【1】为宽;#resized_i原创 2020-06-11 15:09:08 · 138 阅读 · 0 评论 -
Project 6:Mobile APP
Kivy+PythonPython文件控制逻辑定义类;MainApp控制 Rootwidget()#转为执行文件时需要命名为main.pyfrom kivy.app import Appfrom kivy.lang import Builder #连接kvfrom kivy.uix.screenmanager import ScreenManager, ScreenBuilder.load_file("design.kv") #引入kvfileclass LoginScreen(S原创 2020-06-11 10:24:54 · 303 阅读 · 1 评论 -
Install kivy
Installing the LibraryWe will use the kivy library to build a mobile app in Python. Below you will find the instructions on how to install kivy.Important note: Do not simply use pip install kivy to install kivy because even though the command may run wit原创 2020-06-10 13:40:07 · 186 阅读 · 0 评论 -
OOP+继承+术语 Python
银行账户类class Account: def __init__(self,filepath): self.filepath=filepath with open(filepath,'r') as file: self.balance=float(file.read()) def withdraw(self,amount): self.balance-=amount def deposit原创 2020-06-09 18:50:52 · 130 阅读 · 0 评论 -
OOP+Tkinter GUI+SQLlite+Desktopexe——python
Frontend定义对象:database=Database()此Database为 backend中定义的类;类中函数用到的变量,都需要加self. 相当于类中的全局变量;""" A program that stores this book information:Title, Authoryear,ISBNuser can:View all recordsSearch an entryAdd entryUpdate entryDeleteClose"""from原创 2020-06-08 23:29:13 · 222 阅读 · 0 评论 -
Project5: Desktop database application
Desktop database application使用tkinter创建软件界面frontendLabel,Text,Button,Entry;Entry可由textvariable得到输入;Title_text=StringVar()e1=Entry(window,textvariable=Title_text)下面为初始interface代码;""" A program that stores this book information:Title, Authoryear原创 2020-06-08 18:43:25 · 140 阅读 · 0 评论 -
PostgresSQL——Python接口
PostgresSQL需要下载PostgreSQL;本地安装时需要设置密码;操作方式几乎与SQLlite3相同,需要引入psycopg2;#sqlite3 #SQLlite 文件形式储存——易移植 pythonlibrary 中就有,无需西再#psycopg2 #postSQL 需要下载postSQL才能打开,适合网络app的服务器使用#import sqlite3import psycopg2#1.Connect to a database#2.Create a Cursor o原创 2020-06-08 14:48:06 · 308 阅读 · 0 评论 -
SQLlite——python接口
python连接SQLlite的步骤(1)创建连接(2)得到cursor(3)cursor.excute()输入SQL命令(4)commit此次改动(5)断开连接创建SQL文件#sqlite3 #SQLlite 文件形式储存——易移植 pythonlibrary 中就有,无需西再#psycopg2 #postSQL 需要下载postSQL才能打开,适合网络app的服务器使用import sqlite3#1.Connect to a database#2.Create a Cur原创 2020-06-07 15:17:21 · 353 阅读 · 0 评论 -
Tkinter——python制作图形界面
图形界面的初始化tkinter存在于python的builin-lib中,无需install即可import;from tkinter import *#从tkinter导入所有东西window=Tk() #注意大写#创建一个空窗口b1 = Button(window,text="Execute") #传入窗口#还需要传入位置#b1.pack()#传入位置方式2:更好的控制位置b1.grid(row = 0,column=0)e1=Entry(window) #entry原创 2020-06-07 14:31:30 · 490 阅读 · 0 评论 -
Project 3:Personal website
Project 3:Personal website基于python中flask包(library)的personal website开发;本地网页制作准备工作pip install flask在本地(localhost)编辑网页的方法from flask import Flaskapp = Flask(__name__)@app.route('/home/')def home(): return "Website content goes here!"if __nam原创 2020-06-08 18:44:08 · 466 阅读 · 0 评论 -
Project1: English dictionary Json+difflib+SQL
命令行交互:通过给定的单词,搜索加载的json字典库,给出相应的解释json 和 difflib(1)json.load可加载json软件到变量中,保存为字典格式;(2)difflib可进行字符串匹配,get_close_matches可得到匹配度最高的字符串列表list,n为个数,cutoff为百分比;import jsonfrom difflib import get_close_matchesdata=json.load(open("data.json"))def translate原创 2020-06-05 16:11:56 · 189 阅读 · 0 评论 -
Project2: Webmaps
Webmaps(1)可从红黄绿的点中得到美国西部火山的海拔信息等;(2)可从每个国家的地图颜色得到人口多少;(3)可在地图右上角调整图层显示,关闭火山显示或人口显示;使用的工具(1)pandas(调用数据narray)(2)folium(制作地图)导入地图+保存地图import foliumfg=folium.Map(location=[80, -100],zoom_start=6) fg.save("Map3.html") #保存地图folium.Map可以得到一个世界地图原创 2020-06-05 16:11:34 · 254 阅读 · 0 评论