
Python
文章平均质量分 64
kikook
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[Python] PyQt5 程序 Python 打包 exe
pip install pyinstallerpyinstaller -F -w entry_point.pyentry_point.py 是整个python项目的入口python文件,打包后在dist文件夹中得到entry_point.exe参数说明: -F指定打包后只生成一个exe格式的文件-D–onedir 创建一个目录,包含exe文件,但会依赖很多文件(默认选项)-c–console, –nowindowed 使...原创 2020-05-10 18:00:04 · 286 阅读 · 0 评论 -
[Python] Python3 下载 Chrome 并离线安装
import requestsdef dlChrome(): download_addr = "https://dl.google.com/release2/chrome/P75u-n55vk5df0b5dm5gjq_77.0.3865.120/77.0.3865.120_chrome_installer.exe" f = requests.get(download_addr...原创 2020-05-06 11:26:45 · 486 阅读 · 0 评论 -
[Pycharm] 回退前进快捷键
Ctrl + Alt +leftCtrl + Alt + Right原创 2020-04-30 18:22:49 · 2753 阅读 · 0 评论 -
[Anaconda] Anconda 快速安装 pytorch cpu 版本
首先确定自己要用的版本清华源又没有(通常都有),本教程基于清华源加速加速下载(如果没有请搜索中科大源等)添加常用镜像加速下载:conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/conda config --add channels https://mirrors.t...原创 2020-04-27 12:12:00 · 2189 阅读 · 0 评论 -
在Jupyter Notebook中使用虚拟环境
首先确保这个虚拟环境中已经安装了Jupyter Notebook,如果没装:pip install jupyter在虚拟python环境中执行:(env_name为要在浏览器中下拉选项中展示的该虚拟环境的名称)python -m ipykernel install --user --name=env_name然后刷新浏览器页面...原创 2020-04-19 18:26:28 · 619 阅读 · 0 评论 -
[Python3] 一文搞定Python进阶内容 List Comprehension (列表推导式)
看到这样的python代码,很懵逼???[n for n in range(1, dividend+1) if dividend % n == 0]或者这个:f = list(zip(prob,labels))rank = [values2 for values1, values2 in sorted(f, key=lambda x:x[0])]查了一下,这种写法是lis...原创 2020-03-05 22:26:07 · 1144 阅读 · 1 评论 -
【机器学习】python3中numpy,pandas等科学计算包的使用(持续更新)
本学期选修了《机器学习》,每周两次,每次课都有5-10道编程练习,限时很刺激,做点笔记!numpy中文手册,查着很快很爽:https://www.numpy.org.cn/reference/感恩翻译者和网站的维护者们!1.Numpy常用的1.0 n维数组(ndarray)1.0.1np.array()import numpy as nparray1_6 =...原创 2020-03-26 14:08:44 · 548 阅读 · 0 评论 -
[yolov3] 检查 yolov3 数据标注是否正确
使用方法:1.安装依赖包2.修改:*2.1 labels,有几类,写几类,按0-n增大顺序*2.2 img_dir,修改输入图片路径*2.3 yolo_txt_dir,修改为yolo.txt所在文件路径× 2.4 scale_percent,最终显示的图片的缩放比× 2.5 check_rate,检查的图片的比例× 2.6 color_list,每一类的物体的标记...原创 2020-01-15 18:23:37 · 1150 阅读 · 1 评论 -
[python3] 批量重命名图片为定长0000xxx.xxx的python脚本
#!/usr/bin/env python# -*- coding:UTF-8 -*-# 2020/1/10 修改为通用尾缀可用脚本import osimport random# Img_dir 为图片数据集所在的路径# bias 为最终的偏置量,'-1'表示将图片的名称变短一个字符# 假设原来的图片的名称为 00001234.jpeg# 传入 bias = 1 会让图片...原创 2020-01-10 22:38:27 · 1172 阅读 · 0 评论 -
[pyqt5] 纯python+Mysql写的后台管理系统(高度美化,各种异常处理,代码带注释)
带账号登录,数据库校验,数据库操作,数据Excel导出。联网rpyc模块是独立的,不放进来。1.登录界面登录成功后跳转到日志界面。2.日志界面支持搜索框直接查询;过滤器查询查询结果展示:3.任务管理输入两个键值中的任意一个进行查询,之后自动填充下面的任务名,任务代码,任务描述。接下来可以修改信息或者删除任务。查询+自动填充示例:...原创 2020-01-02 12:39:03 · 4814 阅读 · 8 评论 -
[pyqt5] pyqt5给程序设置图标ico
只需要一行代码:main_window.setWindowIcon(QIcon("path/to/your/ico.ico"))并不需要网上说的将ico文件添加到qrc文件再使用pyrcc5转_rc.py。只需要对应的文件路径是正确的相对路径就可以。实例:运行效果:...原创 2020-01-01 21:25:39 · 6765 阅读 · 2 评论 -
[python] 使用装饰器优雅地定时清除pyqt5绘制窗口的状态栏信息
假设一个Qtwidget中的类里定义了几十个会向状态栏写消息的函数,如果想要优雅地自动清除状态栏的内容,最好是自动清理了,但是又不想一个个去改这几十个函数,此时可以使用装饰器自动地完成这个事情,并留出一个接口,对延时地时间自主可控。1.改造前的函数分析 def register_new_user(self): # 连接数据库nuclear ...原创 2019-12-31 13:58:28 · 694 阅读 · 0 评论 -
[python3] python装饰器 简明教程
过去看了很多博客,都感觉写得不很友好,自己写一篇,从基础讲起,结合代码,帮助读者快速掌握这个python利器。python用了一段时间之后,就会发现有些重复的代码反复出现在各个函数中,有没有办法让这些函数“一键”增加功能呢?python装饰器可以很好地解决这个问题。目录0.预备知识0.1 函数指针0.2 函数指针在python中的用法1.最简单的无参数的函数装饰器...原创 2019-12-30 23:44:18 · 704 阅读 · 0 评论 -
[pyqt5] pyqt5 编写图形界面向 MySQL数据库中写入中文出错
解决方案:指定字符集运行效果:原创 2019-12-29 23:00:36 · 522 阅读 · 0 评论 -
[python3] 可变参数列表
def func(arg1, arg2, *args, **kwargs): print("arg1:", arg1, "arg2:", arg2, "args:", args, "kwargs:", kwargs)func(1, 2, 3, 4, 5, 6, a = 1, b = 2, c = 3, d = 4)原创 2019-11-09 20:17:54 · 773 阅读 · 0 评论 -
[Python3] sys.argv 详解
个人理解:sys.argv 相当于C/C++中的 main函数的main(int * argc, char** argv) 中的argv,用法也是相当类似,举例:测试文件:# testSysArgv.pyimport sysif __name__ == "__main__": if len(sys.argv) > 1: print(sys.argv[1:], se...原创 2019-10-31 11:44:12 · 3306 阅读 · 0 评论 -
[Python3] TypeError: descriptor '__init__' of 'super' object needs an argument
报错代码:from PyQt5.QtWidgets import QApplication, QWidgetfrom PyQt5.QtGui import QIconclass WindowCreator(QWidget): def __init__(self): super.__init__() self.initUI() de...原创 2019-10-31 11:12:56 · 8840 阅读 · 6 评论 -
[Python] Python使用requirements.txt安装类库
切换到含有requirements.txt 的路径下pip install -r requirements.txt生成项目依赖列表并写入 requirements.txtpip freeze > requirements.txt原创 2019-10-09 22:20:14 · 373 阅读 · 0 评论 -
【强化学习】Win10使用anaconda安装Gym环境并运行你的第一个强化学习程序“Hello world”
首先进入anaconda目录创建一个名为Gym的文件夹否则会报错:然后要注意指定python版本:conda install --name Gym python=3.6.6然后如果已经在虚拟环境下了,此时需要首先退出虚拟环境,否则激活Anaconda环境命令无效果:(如果你没有使用虚拟环境,那么忽略deactivate)activate Gym这样就完成了环...原创 2019-09-10 16:55:43 · 19903 阅读 · 18 评论 -
[windows]No module named MySQLdb
pip install PyMySQLand then add this two lines to your Project/Project/init.pyimport pymysqlpymysql.install_as_MySQLdb()Works on WIN and python 3.3+Also works for python2.7 + django1.9.xI...翻译 2019-04-27 21:31:37 · 281 阅读 · 0 评论 -
[Python3]python中的类变量和构造函数分析
本文的目的,就是在python3中找到C++中的构造函数,普通成员变量,静态成员变量的对应方法,并总结易错点我们从普通成员变量开始讨论,下面这段代码,暗藏着问题>>> class T: classNum = 10 def __init__(self): objectNum = 99 def changeNum(self, anotherNum): self...原创 2019-03-02 21:22:49 · 1286 阅读 · 0 评论 -
[Python3]闭包实现求阶乘和经典汉诺塔问题递归求解
首先是经典的汉诺塔问题:(写这个函数的时候,默认的是按照y为开始放有盘子的柱子,z为目标柱子,x为辅助柱子,n为盘子的总数)def hanoi(n, x, y, z): # y -> z is our goal, x is a helper if n == 1: print(y, "->", z) return hanoi(n-1, z, y, x) prin...原创 2019-03-05 17:14:04 · 332 阅读 · 0 评论 -
[Python/Django]Xadmin插件中自定义数据表栏目的叠放顺序和继承关系
问题: Xadmin 默认是读取了所有被注册到 xadmin 的模型生成对应的菜单!这个是没问题的 ,但是xadmin又对菜单做了 "通过菜单名称" 排序.英文状态下我们的排列至少是 a-z排列的,但是一到中文就乱了,完全不符合我们的要求.解决办法: 要到达按照我们 在 django 的 settings.py 中 INSTALLED_APPS 中注册的顺序排列只需要在 Xadmi...转载 2019-02-26 14:16:10 · 878 阅读 · 0 评论 -
[Python/Django]class meta属性详解
通过一个内嵌类 “class Meta” 给你的 model 定义元数据, 类似下面这样:class Foo(models.Model): bar = models.CharField(maxlength=30) class Meta: # ...Model 元数据就是 “不是一个字段的任何数据” – 比如排序选项, admin 选项等等.下面是...转载 2019-02-23 19:49:35 · 3241 阅读 · 1 评论 -
[Python\Django]Error fetching command 'collectstatic'解决办法
首先声明,这个错误并不影响正常运行,只是警告而已,按照转载的博主的方法确实可以消除警告,但后面会出现更严重的问题,甚至无法正常运行,请读者自行选择 版权声明:无论原创随意转载 https://blog.youkuaiyun.com/zahuopuboss/article/details/53854649python manage.py collectstatic报错django.core....转载 2019-02-23 15:45:20 · 999 阅读 · 0 评论 -
【Python】One interesting way to unlock the package(Tuple & Dict)
def unlocker(*args, **kwargs): print(*arg) for key in kwargs.keys(): print(key, ":", kwargs[key])I have to announce that I have grabed something new from the practices:I found tha...原创 2018-10-15 01:29:11 · 159 阅读 · 0 评论 -
【Python3】两种不同的继承方式The two different inheritance method when using python3
During the review of python classes, I found out that i missed the different situation of inheritance in pythonThe first type and the second type: Student.__init__(self,name,age) # s...原创 2018-10-13 16:43:23 · 179 阅读 · 0 评论 -
[python]使用python内置变量表示无穷
使用float("inf")表示正无穷使用-float("inf")表示负无穷原创 2019-05-27 18:52:11 · 261 阅读 · 0 评论 -
[python]n皇后问题,输出所有解
import timecount = 0n = 8G = [] # the whole graphr = [] # each row's statusbl = [] # bottom left to top rightbr = [] # bottom right to top leftdef init(): global n n = int(inpu...原创 2019-05-27 19:54:13 · 1559 阅读 · 0 评论 -
【Anaconda】多个python环境下的报错"virtualenv"' 不是内部或外部命令,也不是可运行的程序
整个解决的过程非常坑,主要是因为VS2017自带python,同时安装的Anaconda也有python,同时添加了环境变量请不要照着做,请看完明白为什么后自己按照原理进行排错首先在cmd中运行python需要激活Anaconda对应的python解释器如上图,提示需要激活conda对应的python环境Win搜索框并查看python的属性,发现默认的python解释器的...原创 2019-09-09 21:07:51 · 6248 阅读 · 5 评论 -
【python】Windows提示 “workon不是内部或外部命令,也不是可运行的程序或批处理程序”
管理员模式运行cmd首先卸载之前安装好的virtualenvwrapper:pip uninstall virtualenvwrapper-win然后重新下载pip install virtualenvwrapper-win原创 2019-09-09 20:46:23 · 2894 阅读 · 1 评论 -
【virtualenv】使用方法
virtualenv --no-site-packages py3source py3/bin/activatedeactivate原创 2019-09-03 12:05:16 · 150 阅读 · 0 评论 -
[python3]matplotlib的报错解决
报错信息:>>> import matplotlib.pyplot as pltTraceback (most recent call last): File "/usr/lib/python3.5/tkinter/__init__.py", line 36, in <module> import _tkinterImportError: No ...原创 2019-07-30 22:25:41 · 1264 阅读 · 0 评论 -
[linux&MacOS] 一次搞定配置并使用virtualenvwrapper
virtualenvwrapper,是一个命令集合,便于操作Python虚拟环境。一次搞定配置并使用virtualenvwrapper目录1.安装virtualenvwrapper2.修改 ~./bashrc 文件2.1 设置WORKON命令创建环境的存放路径2.2 设置python3为默认python解释器2.3 运行shell脚本激活virtualenvwrappe...原创 2019-07-30 20:33:53 · 287 阅读 · 0 评论 -
[Python3]Bellman-Ford的实现及Yen式优化
原理分析见本人Github:https://github.com/youhengchan/Yen-Bellman-Ford/blob/master/group2_ppt_yen.pdf测试数据:原始算法:伪代码:实现:import timegraph_size = 10counter = 0class Edge: def __init__(s...原创 2019-06-11 22:27:03 · 1499 阅读 · 3 评论 -
[Python3]Sherwood 型线性时间选择算法
# sherwood algorithmimport timeimport randomdef time_calculate(): start = time.perf_counter() mid_value = main() end = time.perf_counter() return mid_value, end - startdef s...原创 2019-06-13 13:57:01 · 771 阅读 · 0 评论 -
【Python】The importance of reloading the methods ingerited from the super classes
I have been always considering why should I reload the method that has been defined in the super classes.However the answer on the Internet has always being like "When the function itself is differe...原创 2018-10-13 16:28:07 · 218 阅读 · 0 评论