#First to install numpy and opencv-python
#pip install nimpy opencv-python
from turtle import *
import numpy as np
import cv2
import random
#draw_dot()
def dots(colors,radio):
color(colors)
dot(radio)
colors = ["grey","yellow","green","red","blue","black","pink","white"]
for i in range(600,20,-40):
print(i)
color(colors[random.randint(0,7)])
dot(i)
##==================================================#
##import numpy as np
##import cv2
def main():
# 1.创建白色背景图片
d = 400
img = np.ones((d, d, 3), np.uint8) * 255
# 2.循环随机绘制实心圆
for i in range(0, 100):
# 随机中心点
center_x = np.random.randint(0, high=d)
center_y = np.random.randint(0, high=d)
# 随机半径与颜色
radius = np.random.randint(5, high=d/5)
color = np.random.randint(0, high=256, size=(3, )).tolist()
cv2.circle(img, (center_x, center_y), radius, color, -1)
# 3.显示结果
cv2.imshow("img", img)
cv2.waitKey()
cv2.destroyAllWindows()
if __name__ == '__main__':
main()
分类: Python
-
Python画同心圆(实心)
-
想要爬虫获取百度指数,浏览器的cookie怎么获得?
https://blog.csdn.net/Dar_shen/article/details/106755397
大数据接口 GoPUP-cookbook 百度指数需要 登录后的cookie。
-
用python代码看vip电影
import tkinter as tk import tkinter.messagebox import webbrowser as wb class player: def __init__(self): self.root= tk.Tk() #初始化窗口 self.root.title('VIP视频破解软件v1.0') #窗口名称 self.root.geometry("700x350") #设置窗口大小 #设置窗口是否可变,宽不可变,高可变,默认为True self.root.resizable(width=True,height=True) self.menu= tk.Menu(self.root) self.helpmenu = tk.Menu(self.menu, tearoff=0) self.helpmenu.add_command(label='帮助文档', command=self.about) self.helpmenu.add_command(label='作者信息', command=self.zzxx) self.menu.add_cascade(label='帮助(H)', menu=self.helpmenu) self.root.config(menu=self.menu) self.val= tk.StringVar(value='') self.label1=tk.Label(self.root, text='视频播放通道') self.label1.place(x=20,y=20,width=100,height=20) self.Radio=tk.IntVar(value=1) self.Radio1=tk.Radiobutton(self.root,variable=self.Radio,value=0,text='视频通道1') self.Radio2 = tk.Radiobutton(self.root, variable=self.Radio, value=1, text='视频通道2') self.Radio1.place(x=130,y=20,width=100,height=20) self.Radio2.place(x=250, y=20, width=100, height=20) self.val1=tk.StringVar(value='https://www.iqiyi.com/v_19rqpqcijk.html#vfrm=19-9-0-1') self.link= tk.Label(self.root, text='视频播放链接') self.link.place(x=20, y=60, width=100, height=20) self.movie = tk.Entry(self.root, textvariable=self.val1) self.movie.place(x=130, y=60, width=300, height=20) self.clean=tk.Button(self.root,text='清空',command=self.qk) self.clean.place(x=440,y=60,width=30,height=20) self.warn= tk.Label(self.root, text='将视频链接复制到框内,点击播放VIP视频') self.warn.place(x=50, y=90, width=400, height=20) self.val2=tk.StringVar self.start= tk.Button(self.root, text='播放VIP视频', command=self.Button) self.start.place(x=220, y=140, width=80, height=30) # self.box = tk.Label(self.root,text='Select Resource') # self.box.place(x=50,y=145,width=500,height=70) self.start1 = tk.Button(self.root, text='爱奇艺', command=self.openaqy) self.start1.place(x=100, y=200, width=70, height=30) self.start2 = tk.Button(self.root, text='腾讯视频', command=self.opentx) self.start2.place(x=200, y=200, width=80, height=30) self.start3 = tk.Button(self.root, text='优酷视频', command=self.openyq) self.start3.place(x=300, y=200, width=80, height=30) self.b1=tk.Button(self.root,text='技术博客,点我直达',command=self.refer) self.b1.place(x=200,y=300,width=140,height=40,anchor='nw') self.root.mainloop() def Button(self): a = 'http://17kyun.com/api.php?url=' if self.val1.get() else 'https://api.kk06.top/?url=' #Python骚操作:推倒式 b = self.movie.get() wb.open(a+b) #打开浏览器进行播放 def qk(self): self.movie.delete(0,'end') def openaqy(self): wb.open('http://www.iqiyi.com') def opentx(self): wb.open('http://v.qq.com') def openyq(self): wb.open('http://www.youku.com/') def about(self): abc=''' 经过测试 ,支持站点: 爱奇艺 腾讯 优酷 土豆 芒果 乐视 搜狐 PPTV 华数TV 风行 咪咕 哔哩哔哩 ACfun 暴风 CCTV CNTV 范特西 9i广场舞 搜狐自媒体 M1905视频 看看视频 27盘 虎牙直播 全民直播 战旗直播 人人视频 爆米花 今日头条 天翼视频 糖豆视频 龙珠视频 快手视频 一直播 新浪视频 360小视频 熊猫TV 斗鱼TV 花椒直播 网易公开课 音悦台 秒拍网 美拍网 爱拍 凤凰视频 梨视频 微录客 人民微视频 17173视频 优米视频 m3u8 mp4视频 微博视频 YY视频 私有云资源 ''' tkinter.messagebox.showinfo(title='帮助文件', message=abc) def zzxx(self): msg=''' 作者:cnliutz V信: lds02201003267 技术网站:http://cnliutz.ipyingshe.net/ ''' tkinter.messagebox.showinfo(title='联系方式', message=msg) def refer(self): wb.open('http://cnliutz.uicp.io') player() -
python计算一组数据的平均数、标准差等
from statistics import mean, median, variance, stdev, pvariance, pstdev x=(2,3,4,5,6,7,8,9) y=[22,45,67,89,43,23,45,65,21,33,54,66] print(mean(x),median(x),variance(x),stdev(x),pvariance(x),pstdev(x),sum(x),sum(y)) print("mean={},median={},variance={},stdev={},\ pvariance={},pstdev={},sum={},sumy={}".format(mean(x),median(x),variance(x),stdev(x),\ pvariance(x),pstdev(x),sum(x),sum(y))) -
pypi 镜像使用帮助-清华源
pypi 镜像每 5 分钟同步一次。
临时使用
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package注意,
simple不能少, 是https而不是http设为默认
升级 pip 到最新的版本 (>=10.0.0) 后进行配置:
pip install pip -U pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple如果您到 pip 默认源的网络连接较差,临时使用本镜像站来升级 pip:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U -
python pygal作图
import pygal piechart=pygal.Pie() piechart.add('Dog',6) piechart.add('Cat',4) piechart.add('Hamster',3) piechart.add('Fish',2) piechart.add('Snake',1) #piechart.render() piechart.render_to_file("e:\\dsf.svg") bar = pygal.Bar() bar.title = "bar测试" bar.x_labels = ["1", "2"] bar.add("webp", [20, 30]) bar.add("jpg", [20, 30]) bar.render_to_file("e:\\abc.svg") -
Python打印月历、年历
>>>import calendar >>> sep = calendar.TextCalendar(calendar.SUNDAY) >>> sep.prmonth(2021,9) >>>print(calendar.prcal(2021)) >>> for name in calendar.month_name: print(name) January February March April May June July August September October November December >>> for name in calendar.day_name: print(name) Monday Tuesday Wednesday Thursday Friday Saturday Sunday -
python tkinter调用Windows命令和程序
import tkinter as tk #import sys import os root = tk.Tk() def open_calc(): os.system("calc") def open_chrome(): os.system("start chrome") def open_code(): os.system("Code") root.title("Thonny window") lbl1 = tk.Label(root,text='Python IDE Thonny.org') lbl1.pack(side="top") btn=tk.Button(root,text='Start 计算器',command=open_calc) btn.pack(side='left') btn=tk.Button(root,text='Start Chrome Browser浏览器',command=open_chrome) btn.pack(side='top') btn=tk.Button(root,text='Start vs Code',command=open_code) btn.pack(side='bottom') root.mainloop() -
查看Python安装目录
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> import os >>> os.__file__ 'C:\\Program Files\\Python38\\lib\\os.py' >>> -
计算器tkinter代码
#filename:Caculater import tkinter,time,decimal,math,string root=tkinter.Tk() root.title('计算器') root.resizable(0,0) global cuncu, vartext, result, fuhao result = fuhao = None vartext = tkinter.StringVar() cuncu = [] class anjianzhi: global cuncu, vartext, result, fuhao def __init__(self,anjian): self.anjian = anjian def jia(self): cuncu.append(self.anjian) vartext.set( ''.join(cuncu)) def tui(self): cuncu.pop() vartext.set(''.join(cuncu)) def clear(self): cuncu.clear() vartext.set('') result = None fuhao = None def zhengfu(self): if cuncu[0]: if cuncu[0] == '-': cuncu[0] = '+' elif cuncu[0] == '+': cuncu[0] = '-' else: cuncu.insert(0, '-') vartext.set(''.join(cuncu)) def xiaoshudian(self): if cuncu.count('.') >= 1: pass else: if cuncu == [] : cuncu.append('0') cuncu.append('.') vartext.set(''.join(cuncu)) def yunshuan(self): global cuncu, vartext, result, fuhao if vartext.get() == '': pass else: get1 = decimal.Decimal(vartext.get()) if self.anjian in ('1/x','sqrt'): if self.anjian == '1/x': result = 1/get1 elif self.anjian == 'sqrt': result = math.sqrt(get1) elif self.anjian in ('+','-','*','/','='): if fuhao is not None: get1 = decimal.Decimal(result) get2 = decimal.Decimal(vartext.get()) if fuhao == '+': result = get1 + get2 elif fuhao == '-': result = get1 - get2 elif fuhao == '*': result = get1 * get2 elif fuhao == '/': result = get1 / get2 else: result = get1 if self.anjian == '=': fuhao = None else: fuhao = self.anjian print(fuhao) print(result) vartext.set(str(result)) cuncu.clear() def copy1(): # tkinter.Misc().clipboard_clear() tkinter.Misc().clipboard_append(string(vartext.get())) def buju(root): global cuncu, vartext, result, fuhao entry1 = tkinter.Label(root, width=30, height=2, bg='white', anchor='se', textvariable=vartext) entry1.grid(row=0, columnspan=5) buttonMC=tkinter.Button(root,text='MC',width=5) buttonMR=tkinter.Button(root,text='MR',width=5) buttonMS=tkinter.Button(root,text='MS',width=5) buttonM1=tkinter.Button(root,text='M+',width=5) buttonM2=tkinter.Button(root,text='M-',width=5) buttonMC.grid(row=1,column=0) buttonMR.grid(row=1,column=1) buttonMS.grid(row=1,column=2) buttonM1.grid(row=1,column=3) buttonM2.grid(row=1,column=4) buttonJ=tkinter.Button(root,text='←',width=5,command=anjianzhi('c').tui) buttonCE=tkinter.Button(root,text='CE',width=5) buttonC=tkinter.Button(root,text=' C ',width=5,command=anjianzhi('c').clear) button12=tkinter.Button(root,text='±',width=5,command=anjianzhi('c').zhengfu) buttonD=tkinter.Button(root,text='√',width=5,command=anjianzhi('sqrt').yunshuan) buttonJ.grid(row=2,column=0) buttonCE.grid(row=2,column=1) buttonC.grid(row=2,column=2) button12.grid(row=2,column=3) buttonD.grid(row=2,column=4) button7=tkinter.Button(root,text=' 7 ',width=5,command=anjianzhi('7').jia) button8=tkinter.Button(root,text=' 8 ',width=5,command=anjianzhi('8').jia) button9=tkinter.Button(root,text=' 9 ',width=5,command=anjianzhi('9').jia) buttonc=tkinter.Button(root, text=' / ',width=5,command=anjianzhi('/').yunshuan) buttonf= tkinter.Button(root, text=' % ',width=5) button7.grid(row=3,column=0) button8.grid(row=3,column=1) button9.grid(row=3,column=2) buttonc.grid(row=3,column=3) buttonf.grid(row=3,column=4) button4=tkinter.Button(root,text=' 4 ',width=5,command=anjianzhi('4').jia) button5=tkinter.Button(root,text=' 5 ',width=5,command=anjianzhi('5').jia) button6=tkinter.Button(root,text=' 6 ',width=5,command=anjianzhi('6').jia) buttonx=tkinter.Button(root,text=' * ',width=5,command=anjianzhi('*').yunshuan) buttonfs=tkinter.Button(root,text='1/x',width=5,command=anjianzhi('1/x').yunshuan) button4.grid(row=4,column=0) button5.grid(row=4,column=1) button6.grid(row=4,column=2) buttonx.grid(row=4,column=3) buttonfs.grid(row=4,column=4) button1 = tkinter.Button(root, text=' 1 ',width=5,command=anjianzhi('1').jia) button2 = tkinter.Button(root, text=' 2 ',width=5,command=anjianzhi('2').jia) button3 = tkinter.Button(root, text=' 3 ',width=5,command=anjianzhi('3').jia) button_= tkinter.Button(root, text=' - ',width=5,command=anjianzhi('-').yunshuan) buttondy= tkinter.Button(root, text=' \n = \n ',width=5,command=anjianzhi('=').yunshuan) button1.grid(row=5, column=0) button2.grid(row=5, column=1) button3.grid(row=5, column=2) button_.grid(row=5, column=3) buttondy.grid(row=5, column=4,rowspan=2) button0=tkinter.Button(root,text=' 0 ',width=11,command=anjianzhi('0').jia) buttonjh = tkinter.Button(root,text=' . ',width=5,command=anjianzhi('c').xiaoshudian) buttonjia=tkinter.Button(root,text=' + ',width=5,command=anjianzhi('+').yunshuan) button0.grid(row=6,column=0,columnspan=2) buttonjh.grid(row=6,column=2) buttonjia.grid(row=6,column=3) def caidan(root): menu=tkinter.Menu(root) submenu1=tkinter.Menu(menu,tearoff=0) menu.add_cascade(label='查看',menu=submenu1) submenu2 = tkinter.Menu(menu, tearoff=0) submenu2.add_command(label='复制') submenu2.add_command(label='粘贴') menu.add_cascade(label='编辑',menu=submenu2) submenu = tkinter.Menu(menu, tearoff=0) submenu.add_command(label='查看帮助') submenu.add_separator() submenu.add_command(label='关于计算机') menu.add_cascade(label='帮助',menu=submenu) root.config(menu=menu) buju(root) caidan(root) root.mainloop()

