Python
baiyuwujia
这个作者很懒,什么都没留下…
展开
-
NVIDIA驱动问题解决方案:Failed to initialize NVML: driver/library version mismatch
https://my.oschina.net/wangsifangyuan/blog/1606093原创 2020-07-09 17:24:07 · 4505 阅读 · 0 评论 -
docker容器flaskweb服务
1.需要有空闲映射窗口https://blog.csdn.net/MissShihong/article/details/103313396?utm_medium=distribute.pc_relevant.none-task-blog-baidujs-12. app.run(host='0.0.0.0', port = xxxx, debug=True)若要外部访问,则host必须0.0.0.0原创 2020-07-08 16:29:56 · 213 阅读 · 0 评论 -
pip install opencv-contrib-python
https://www.pyimagesearch.com/2018/09/19/pip-install-opencv/原创 2020-07-02 14:06:39 · 2923 阅读 · 0 评论 -
numpy数组统计元素个数
一维可以直接用Counter,二维需用flatten展开,三维如需分通道统计则遍历每一通道再用二维from collections import Counterprint(Counter(image.flatten()))原创 2020-05-13 10:32:06 · 21528 阅读 · 0 评论 -
Numpy元素个数统计、根据条件修改元素值
data数组中小于1的元素都替换为0data [data < 1.0] = 0统计元素个数:import numpy as npfrom collections import Countera = np.array([[1,2],[3,4]])Counter(a.flatten()) # 二维数组需展平统计Out: Counter({1: 1, 2: 1, 3: ...原创 2020-03-03 21:21:47 · 4704 阅读 · 0 评论 -
qt-5.9.7-vc14h73c81de_0
github参考问题:https://github.com/ContinuumIO/anaconda-issues/issues/10949报错信息:ERROR conda.core.link:_execute(700): An error occurred while installing package 'defaults::qt-5.9.7-vc14h73c81de_0'.Rol...原创 2019-12-24 17:09:42 · 5762 阅读 · 4 评论 -
python函数定义中的冒号和箭头
定义:def f(ham: str, eggs: str) -> str: ''' :str提醒你传一个str,但并不能约束你 -> str 提醒你目标返回值是一个str,但并不能约束你 ''' return ham + eggsprint(f('a','b'))print(f(1,2))print(f('a',1)...原创 2019-12-06 14:02:46 · 1497 阅读 · 1 评论 -
服务器运行程序不会因挂断连接而中断:nohup
XShell连接服务器,程序经常因为关掉XShell就会被中断解决方法:nohup python XX.py 1>path_log 2>path_error &(1) 最后的&符号表示不挂断(2) 1> 后给出日常日志路径(3) 2> 后给出错误路径(4) 其他用法:nohup XX.py 2>error.out &am...原创 2019-11-28 13:38:11 · 761 阅读 · 0 评论 -
ImportError: dlopen: cannot load any more object with static TLS
该问题在使用import torch时出现。这是一个非常诡异的问题,可以发现在github有大量关于该问题的讨论,然而并没有一个根本性的解决方法,并且该问题并不仅仅在使用torch时出现,用tensorflow也有可能出现。解决方法:1、调换调用包的顺序,例如:import cv2import torch # 报错# different orderimport torch...原创 2019-11-11 13:54:23 · 4396 阅读 · 4 评论 -
python命令行标准解析库:argparse
官方Tutorial:https://docs.python.org/3/howto/argparse.html#id1中文参考:https://www.cnblogs.com/dengtou/p/8413609.htmlargparse:the recommended command-line parsing module in the Python standard library...原创 2019-11-05 14:40:41 · 362 阅读 · 0 评论 -
from easydict import EasyDict as edict
easydict,顾名思义,可以很easy地使用dict,在PyPI解释:https://pypi.org/project/easydict/EasyDictallows to access dict values as attributes (works recursively). A Javascript-like properties dot notation for python d...原创 2019-10-30 13:57:32 · 2915 阅读 · 0 评论 -
Python项目中的setup.py
在github上参考别人的代码时,总会有使用setup.py去构建环境这一项,那么setup.py究竟是什么东西?setup.py : python环境/包的构建工具参考博客:https://blog.csdn.net/whatday/article/details/90767387 setup如何编辑 https://blog.csdn.net/HaigL...原创 2019-10-29 17:19:41 · 2843 阅读 · 0 评论 -
python包的相对导入和绝对导入
绝对导入:从要导入文件的顶级包开始写起print(__package__) # 打印出该文件所在包的路径以下面所示项目文件结构为例:# 顶级包一般是项目文件夹中最上层的包,比如说a,b中的模块的顶级包就分别是a,b# a1中print(__package__) >> a# b1中print(__package__) >> b...原创 2019-10-19 21:34:22 · 619 阅读 · 0 评论 -
from __future__ import 是什么东东?
from __future__ import XXX # 引入新版本的功能模块,你写python2也得按照python3的写法来举个栗子:from __future__ import print_function# 即使在python2.X,使用print就得像python3.X那样加括号# python2.7print "Hello world"# pytho...原创 2019-10-18 16:36:41 · 259 阅读 · 0 评论