自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 CSS去除按钮激活的高亮边框(Button的点击出现黑色外边框的取消)

去除之前,关闭按钮有高亮边框给元素加上id,在css中添加两行去除边框和外显就行,这是去除之后

2020-07-31 13:58:52 3661

原创 JS中判断今天是今年第几周

<!DOCTYPE html><html> <head> <meta charset="utf-8"> <script src="js/jquery-3.4.1.min.js"></script> <title></title> </head> <body> <p></p> </body> <script> v

2020-07-31 12:23:52 1332

原创 Python摄像头录制视频保存到本地

from os import mkdirfrom os.path import isdirimport datetimefrom time import sleepfrom threading import Threadimport cv2def write(): while cap.isOpened(): ret, frame = cap.read() if ret: #写入视频文件 aviFile.write(fram

2020-07-28 10:50:30 1887 3

原创 Python升级pip并安装opencv、moviepy包

在环境变量中新建python目录路径python -m pip install --upgrade pip升级pip,pip install opencv-python安装opencv包

2020-07-28 10:19:21 1180 1

原创 Python简单GUI(录音机)

import waveimport threadingimport tkinterimport tkinter.filedialogimport tkinter.messageboximport pyaudioroot = tkinter.Tk()root.title('Recorder')root.geometry('270x80+550+300')root.resizable(False, False)fileName = NoneallowRecording = False

2020-07-28 08:48:50 919

原创 Python制作彩色验证码

from random import choice, randint, randrangeimport stringfrom PIL import Image, ImageDraw, ImageFont#返回length长度随机字母和数字def selectedCharacters(length): result = ''.join(choice(string.ascii_letters+string.digits) for _ in range(length)) return r

2020-07-27 13:28:17 316

原创 Python绘制3D图(键盘控制)

import sysfrom OpenGL.GL import *from OpenGL.GLUT import *from OpenGL.GLU import *from PIL import Imageclass MyPyOpenGLTest: def __init__(self, width=640, height=480,title="Keyboard Control"): glutInit(sys.argv) glutInitDisplayMod

2020-07-26 12:51:23 989

原创 Python安装OpenGL包

1.下载对应的OpenGL包:https://www.lfd.uci.edu/~gohlke/pythonlibs/2.在本地磁盘找到下载好的包,我的版本是Python3.83.在cmd中进入此目录,安装两个.whl文件4.再导入包就不会报错了

2020-07-26 12:11:40 2173

原创 Python对MySQL数据库的创建,增删改查操作

import pymysql#连接数据库conn = pymysql.connect(host='127.0.0.1', user='root', password='SQL123', database='experiment', charset='utf8')def doSQL(sql): cursor.e

2020-07-25 11:12:25 271

原创 Python使用管道实现进程间数据传递

from multiprocessing import Process, Pipedef f(conn): conn.send('Hello World!') #向管道中发送数据 conn.close()if __name__ == '__main__': conn_A, conn_B = Pipe() #创建管道对象 p = Process(target=f, args=(conn_A,)) #将管道的一方给子进程 p.start()

2020-07-25 09:47:30 724

原创 Python的BoundedSemaphore对象和Pool对象实例

BoundedSemaphore对象:from threading import Thread, BoundedSemaphorefrom time import time,sleepdef execute(i): start=time() with sem: end=time() print("Thread: {0} waiting time:{1}".format(i,end-start)) sleep(2) se

2020-07-24 13:46:28 332

原创 Python的Lock对象和Condition对象对比

Lock对象:import threadingimport timeclass myThread(threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): global x lock.acquire() #当前线程锁定,阻塞其他线程 for i in range(10): x+

2020-07-23 14:13:51 476

原创 Python线程类调用普通方法

import threadingimport timeclass myThread(threading.Thread): def __init__(self,name): threading.Thread.__init__(self) self.name=name def run(self): print("thread run()") def showMess(self): print("class method:

2020-07-23 12:21:51 478

原创 Python创建多线程(join线程同步)

import threadingimport timedef timer(v): #定时器线程函数 print(v) def demo(x,y): for i in range(x,y): print(i,end=" ") time.sleep(5) #线程挂起5秒 t=threading.Timer(2,timer,args=(1,)) #2秒后执行定时器t2=threading.Timer(0.5,

2020-07-22 15:17:16 241

原创 Python爬取网页源码,图片和文字到本地

import reimport osimport os.pathfrom time import sleepfrom urllib.parse import urljoinfrom urllib.request import urlopenfrom multiprocessing import Pooldef crawlUrl(item): perUrl,name=item perUrl=urljoin(url,perUrl) #资源网页绝对路径 name=

2020-07-20 14:15:44 1054

原创 Python查看本机所有联网应用程序信息

from os.path import basenamefrom psutil import net_connections, Processprint(" 程序文件名:\t\t本地地址:\t\t\t\t\t远程地址:\t\t\t\t连接状态:")for conn in net_connections('all'): laddr, raddr, status, pid = conn[3:] if not raddr: continue else:

2020-07-19 16:50:36 399

原创 Python套接字通信(多线程自动回复机器人)

Receiverimport socketfrom os.path import commonprefixwords = {'hello':'Hello', 'Who are you?':'Servicer', 'over':'Over'}HOST = ''PORT = 5000s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)s.bind((HOST, PORT)) #绑定地址s.

2020-07-19 10:09:22 446

原创 Python套接字通信实例

Sender:import socket#创建一个socket对象,#socket.AF_INET表示IPV4,socket.AF_INET6表示IPV6#socket.SOCK_STREAM表示TCP协议,socket.SOCK_DGRAM表示UDP协议s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)mess=""while mess.lower()!="over": mess=input("Please input the s

2020-07-18 18:55:16 389

原创 Python简单GUI(模拟画图)

import osimport tkinterimport tkinter.simpledialogimport tkinter.colorchooserimport tkinter.filedialogfrom PIL import Imagefrom PIL import ImageGrabdef openItem(): global img filename=tkinter.filedialog.askopenfilename(title="Open",filetype

2020-07-15 12:38:00 1614

原创 Python简单GUI(模拟图片查看器)

import osimport tkinterimport tkinter.messageboxfrom PIL import Image, ImageTkdef init(): global curP curP=0 changePic()def clickPre(): global curP if curP==0: tkinter.messagebox.showinfo("Error", "This is the first pictu

2020-07-14 09:56:12 1235

原创 Python简单GUI(猜随机数)

import tkinterimport tkinter.messageboxfrom tkinter.simpledialog import askintegerimport randomdef init(): entryNum['state'] = "disabled" btnConfirm['state'] = "disabled"def confirm(): global guessNum global count count[0] += 1

2020-07-13 12:41:58 373

原创 Python简单GUI(随机点名)

import tkinterimport tkinter.messageboximport randomimport threadingimport itertoolsimport timedef closeWindow(): root.flag=False time.sleep(0.1) #延迟0.1秒执行 root.destroy()def clickStart(): t=threading.Thread(target=shuffleUsers)

2020-07-12 16:59:39 1356 1

原创 Python简单GUI(模拟放大镜)

import tkinterfrom PIL import ImageGrab, ImageTkroot=tkinter.Tk()screenW=root.winfo_screenwidth()screenH=root.winfo_screenheight()root.geometry(str(screenW)+'x'+str(screenH)+'+0+0')root.overrideredirect(True) #不显示标题栏root.resizable(False,False)

2020-07-09 11:15:17 1874

原创 Python提示ModuleNotFoundError: No module named ‘PIL‘,已解决

提示错误:这是因为缺少pillow包,解决:1.在环境变量Path中新建python安装目录下的Scripts路径2.打开cmd输入:pip install pillow安装安装成功后,import PIL就不会报错了

2020-07-09 09:19:03 18241

原创 Python出现AttributeError: module ‘tkinter‘ has no attribute ‘messagebox‘,已解决

Python使用对话框显示提示信息出现无messagebox属性解决:引入tkinter.messagebox包即可import tkinter.messagebox

2020-07-09 08:50:46 9593

原创 Spring MVC文件上传下载实例

工程目录:导入jar:controllers.FileControler.javapackage controllers;import java.io.File;import java.io.*;import java.io.IOException;import java.io.InputStream;import javax.servlet.ServletContext;import javax.servlet.http.HttpSession;import org.spring

2020-07-08 14:15:59 215

原创 Spring MVC登录实例

工程目录结构:导入jar:controllers.LoginController.javapackage controllers;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import or

2020-07-08 12:14:48 423

原创 python的简单GUI(模拟计算器)

import tkinterimport reoperators=('+','-','*','/','**','//')def buttonClick(btn): val=contentVar.get() if val.startswith('.'): val='0'+val if btn in '0123456789': val+=btn elif btn=='.': t=re.split(r'\+|-|\*|/]'

2020-07-06 10:07:16 601

原创 python的简单GUI(多线程时钟)

import tkinterimport threadingimport datetimeimport timeroot=tkinter.Tk()root.overrideredirect(True) #覆盖标题栏root.attributes('-alpha',0.5) root.attributes('-topmost',1) #保持前置root.geometry('200x50+1200+50') #初始大小和位置x=tkinter

2020-07-03 15:23:20 831

原创 python简单GUI(模拟记事本)

import tkinter.filedialogimport tkinter.messageboximport tkinter.scrolledtextimport tkinter.simpledialogroot = tkinter.Tk()root.title("Notepad")root['width'] = 200root['height'] = 300filename="E://无标题.txt"textChanged=tkinter.IntVar(root,value=0)

2020-07-02 17:25:25 1039

原创 python的简单GUI(数据绑定与listbox)

import tkinterimport tkinter.messageboximport tkinter.ttkclasses={'1':['z1','z2','z3','z4'], '2':['l1','l2','l3'], '3':['m5','m6','m7','m8']}root=tkinter.Tk()root.title("GUI TWO")root['height']=300root['width']=270def changeCla

2020-07-01 18:53:31 627

原创 python的全局变量 local variable ‘xxx‘ referenced before assignment

在python中一个方法中更改全局变量出错解决方法:在这个方法体中给全局变量前加globalerrorTimes=0def f(): global errorTimes errorTimes+=1 print(errorTimes)

2020-07-01 10:39:50 886

原创 python的简单GUI(登录窗口)

用到了tkinter包,勾选记忆后用户名和密码会以文件的形式保存在本地磁盘import tkinterimport tkinter.messageboximport osf_path="E://gui.txt"def autoFill(): try: with open(f_path,'r') as fp: name,pwd=fp.read().strip().split(',') varName.set(name)

2020-07-01 09:52:44 1533

空空如也

空空如也

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

TA关注的人

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