
python
文章平均质量分 55
AI 开发者
支付宝软件工程师
展开
-
python线程安全的单例模式
一、默认情况实例化几次,就有几个实例。1.1 单线程import timeclass Singleton: def __init__(self): time.sleep(1) print('init successfully')if __name__ == '__main__': obj1 = Singleton() obj2 = Singleton() obj3 = Singleton() print(id(obj1))原创 2021-05-03 13:52:35 · 1434 阅读 · 2 评论 -
10进制转62进制JavaScript和Python实现
encode(number) { let chars = '0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ'.split('') let radix = chars.length let qutient = number let arr = [] do { let mod = qutient % radix; qutient = (qutient - mod) / r原创 2021-01-15 13:25:29 · 839 阅读 · 2 评论 -
MacOS 完全卸载自己安装的 Python
以 Python3.7 为例1.删除 Python 框架sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.72.删除 Application 中的目录sudo rm -rf /Applications/Python\ 3.7/3.删除bin中的连接查看连接cd /usr/local/bin/ls -l /usr/local/bin | grep '/Library/Frameworks/Python.framework原创 2020-11-27 19:11:10 · 1976 阅读 · 1 评论 -
Python 网络请求 SSL: CERTIFICATE_VERIFY_FAILED
在网络请求前添加如下代码:import os, sslif (not os.environ.get('PYTHONHTTPSVERIFY', '') and getattr(ssl, '_create_unverified_context', None)): ssl._create_default_https_context = ssl._create_unverif...原创 2019-07-15 16:25:54 · 619 阅读 · 0 评论 -
Pycharm创建新文件时,自动添加头文件注释
1.选择Pycharm-Preferences (Windows下为File-Settings)2.选择File and Code Templates -> Files -> Python Script3.填写你想要的头注释格式,点OK4.新建一个py文件,效果如图...原创 2019-01-15 16:03:26 · 4152 阅读 · 0 评论 -
pip安装pycurl报错
pip install pycurl报错提示如下:Curl is configured to use SSL, but we have not been able to determinewhich SSL backend it is using. Please see PycURL documentation for howto specify the SSL backend ma...原创 2018-11-30 09:14:50 · 17074 阅读 · 2 评论 -
plot_model 报错 "Failed to import pydot. You must install pydot and graphviz for 'pydotprint' to work"
plot_model 是 keras 中自带的一个可视化工具,可以将网络结构生成如下图所示的图片。使用:from keras.utils import plot_modelplot_model(model,to_file='model.png')但是有时会报错:keras ImportError: Failed to import pydot. You must in...原创 2018-11-19 15:28:16 · 1472 阅读 · 0 评论 -
python 分割字母和数字
from itertools import groupbys = 'Chevrolet3986_small.jpg'print(s)ss = [''.join(list(g)) for k, g in groupby(s, key=lambda x: x.isdigit())]print(ss[0])print(ss[1])print(ss[2])运行结果:...原创 2018-11-14 18:59:57 · 35466 阅读 · 0 评论 -
pip 安装库时速度很慢的解决方法
常用的pip国内源:阿里云 https://mirrors.aliyun.com/pypi/simple/ 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 豆瓣(douban) https://pypi.douban.com/simple/ 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/ 中...原创 2018-11-15 19:35:33 · 27743 阅读 · 0 评论 -
Mac OS配置virtualenv环境
virtualenv 是一个python库,用来为一个应用创建一套“隔离”的Python运行环境。为每个应用单独建立一个环境可以避免python库版本的混乱。(使用mac或linux的终端)首先安装pip :sunshuaideMacBook-Pro:~ sunshuai$ sudo easy_install pip 然后使用pip安装virtualenv:sunshuai...原创 2018-10-21 21:37:14 · 1897 阅读 · 0 评论 -
常用的Python爬虫
1.微信公众号爬虫GitHub:https://github.com/Chyroc/WechatSogou基于搜狗微信搜索的微信公众号爬虫接口,可以扩展成基于搜狗搜索的爬虫,返回结果是列表,每一项均是公众号具体信息字典。2.豆瓣读书爬虫GitHub:https://github.com/lanbing510/DouBanSpider可以爬下豆瓣读书标签下的所有图书,按评分排名依次存...转载 2018-01-21 11:55:00 · 1401 阅读 · 0 评论