- 博客(7)
- 收藏
- 关注
原创 Flask中表单验证接收空为None,而不是False
Flask中BooleanField只接受’false’或者None为False,其他值都接收为True,0、false、'0’也为True如果想更改BooleanField接收None为None的话,就需要重新定义BooleanField。class MyBooleanField(wtf.BooleanField): def __init__(self, label=None, va...
2019-04-14 22:12:14
2683
原创 使用python,Excel中横坐标数字和字母相互转换
横坐标转换为数字,比如:AA转换为27def colname_to_num(colname): if type(colname) is not str: return colname col = 0 power = 1 for i in range(len(colname)-1,-1,-1): ch = colname[i] ...
2019-04-14 16:24:34
2841
6
原创 Flask HttpResponse 响应体中返回 openpyxl 生成的 Excel 文档
Flask HttpResponse 响应体中返回 openpyxl 生成的 Excel 文档现在我需要提供一个链接,访问时通过 openpyxl 动态生成一个 Excel 文档,并作为响应体返回。在这里将动态生成的 Excel 文档保存到服务器,并重定向到静态文件链接显然不是一个合适的做法。所以我们需要直接将 openpyx 生成的 Excel 文档写入到 Flask 的 HttpRes...
2019-04-14 14:56:49
2263
原创 Decimal使用以及遇到的问题
项目中有小数计算,需要限制小数点后两位,float类型计算有误差,于是使用decimal类型计算用法1、可以通过限制decimal环境条件。from decimal import Decimal, getcontext, setcontextgetcontext().prec = 2# 也可以直接设置decimal环境变量mycontext = Context(prec=2, rou...
2019-03-15 15:36:01
12819
2
原创 使用numpy库报错,TypeError: Object of type 'int64' is not JSON serializable.
项目中需要大量列表中的数字相加,于是使用numpy库,但是在json转换时报错。开始以为是含有numpy类型的字典不能转换为json字符串,后来转换成list依然没有解决。google后,找到解决办法,重新定义json类。class NumpyEncoder(json.JSONEncoder): """ Special json encoder for numpy types """...
2019-03-12 18:19:24
2205
原创 数据库迁移表时报错:alembic.util.exc.CommandError: Target database is not up to date.
报错代码INFO [alembic.runtime.migration] Context impl PostgresqlImpl.INFO [alembic.runtime.migration] Will assume transactional DDL.Traceback (most recent call last): File "/Users/FiveMeter/Desktop...
2019-03-08 11:08:20
2684
1
原创 mac更新为Mojave 10.14时,安装环境报错
mac更新为Mojave 10.14时,安装环境报错mac新更新的mojave 10.14系统,结果安装项目环境依赖时报错。clang: error: no such file or directory: 'build/temp.macosx-10.9-x86_64-3.6/_imagingtk.o'clang: error: no such file or directory: 'buil...
2019-02-28 12:40:20
1368
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人