python
leo安静
神即道,道法自然,如来
展开
-
mac上的pip安装
环境:mac软件:vscode全新电脑,用pip install xxx 安装时报错,需要下载pip,但是一直报错找不到最终解决方案:1.在以下地址下载最新的PIP安装文件:http://pypi.python.org/pypi/pip#downloads2.下载pip-20.2.3.tar.gz(1.5 MB)完成之后,解压到一个文件夹,用CMD控制台进入解压目录,输入python setup.py install成功安装install...原创 2020-09-22 16:21:18 · 956 阅读 · 1 评论 -
ModuleNotFoundError: No module named 'socketio' 解决方案
正确安装的写法:pip install python-socketio如果还是安装不了,去官网https://pypi.org/project/python-socketio/,下载安装包安装原创 2020-03-06 01:34:59 · 5770 阅读 · 0 评论 -
python logging报错UnicodeEncodeError: 'charmap' codec can't encode characters in position
使用python的logging模块记录日志,有时会遇到中文编码问题错误。解决方案:在logging.FileHandler(path) 中添加指定编码方式encoding='utf-8'即可,logging.FileHandler(path,encoding='utf-8')...原创 2020-02-04 00:29:55 · 5254 阅读 · 2 评论 -
The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
运行以下代码:condition1 = df['MACD'] < 0 and df['MACD'].shift(3) > 0condition2 = df['DIF'] < 0 and df['DIF'].shift(3) > df['DEA']condition3 = df['volume'] > df['volume_ma']*ndf.loc[cond...原创 2020-01-05 22:19:39 · 4405 阅读 · 0 评论 -
python列表合并+排序的解决方法
在编写列表合并的代码时,遭遇了合并后的列表无法排序的问题。a = [1,2,3,4,5]b = [1,5,7,9]c = a+bprint(c)print(c.sort())print(c.sorted())执行结果:[1, 2, 3, 4, 5, 1, 5, 7, 9]NoneTraceback (most recent call last): File "1....原创 2018-06-25 13:40:34 · 8519 阅读 · 5 评论 -
用python连接bibox交易所的websocket接口
本人自学python水平有限,耗费3天时间调试成功了这个websocket接口。实在是官方文档没有python实现的demo,网络上又根本搜索不到相关信息,自己硬生生琢磨出来的。全当抛砖引玉,请各位看官指点。以下内容属于最小可行性版本,功能逐步扩展:import gzipimport jsonimport websocketimport sslimport base64cla...原创 2019-06-10 18:22:02 · 2017 阅读 · 0 评论 -
python中base64加密和解密
import base64# 给定需要转换的字符串str1 = "你好"# 需要转成2进制格式才可以转换,所以我们这里再手动转换一下result = base64.b64encode(str1.encode())# 打印转换后的结果print('转换后的结果 --> ' + str(result))# 再把加密后的结果解码temp = base64.b64...原创 2019-06-10 16:52:58 · 1232 阅读 · 0 评论 -
module 'websocket' has no attribute 'enableTrace' 解决方案
import websocketwebsocket.enableTrace(True)ws = websocket.WebSocketApp("wss://stream.binance.com:9443/ws/!ticker@arr", on_message = on_messa...原创 2019-06-06 10:57:09 · 21952 阅读 · 1 评论 -
ValueError: the indices for endog and exog are not aligned 解决方案
在运行以下代码时x = data1 # service类型数据y = data2X = sm.add_constant(x)result = (sm.OLS(y, X)).fit()print(result.summary)报错:ValueError: the indices for endog and exog are not aligned解决思路:1、...原创 2019-01-22 15:58:57 · 15759 阅读 · 2 评论 -
用Python处理非平稳时间序列(附代码)
原文地址:https://blog.csdn.net/tmb8z9vdm66wh68vx1/article/details/84207895由于排版和图片原因,请尽量转制原文观看,在此只是作为个人的一个记录。作者:AISHWARYA SINGH翻译:陈之炎校对:丁楠雅本文约3600字,建议阅读10分钟。本文将重点介绍时间序列数据的平稳性检验方法。 ...转载 2018-12-20 13:10:31 · 807 阅读 · 0 评论 -
python adf单位根检验 如何查看结果
执行程序后,会显示如下内容:test statistic简称为T值,表示t统计量p-value简称为p值,表示t统计量对应的概率值lags used表示延迟number of observations used表示测试的次数critical value1% 表示如果t值小于-3.431921,则原假设发生的概率小于1%。其他数值以此类推。其中t值和p值是最重要的,其实t...原创 2018-12-19 15:22:51 · 16833 阅读 · 2 评论 -
python获取时间及时间格式转换
整理总结一下python中最常用的一些时间戳和时间格式的转换第一部分:获取当前时间和10位13位时间戳import datetime, time'''获取当前时间'''n = datetime.datetime.now()print(n)'''获取10位时间戳'''now = time.time()print(int(now))'''获取13位时间戳'''now2 ...原创 2018-12-06 11:26:04 · 1059 阅读 · 0 评论 -
mongodb集合为数字时,如何获取数据?
由于工作原因,有很多的mongodb的集合都是以数字命名,保存数据时没有任何问题,读取数据时遇到了麻烦。当按照正常方法读取collection数据时data = db.123456会报错,语法错误:SyntaxError: invalid syntax经过查询,网上提供的一种方法是:data = db.getCollection('123456')但是同样会报错:...原创 2018-12-12 17:18:58 · 1437 阅读 · 0 评论