- 博客(22)
- 资源 (7)
- 收藏
- 关注
原创 python下实现jsonp
在高德地图加载热力图时,数据支持jsonp,通过python实现:1、后台python:# 通过jsonp格式返回热力图的数据def heatjsonp(request): funcname = request.GET.get('callback') # print(funcname) content = '%s(%s)' % (funcname, heatdata())...
2018-04-27 11:21:39 3670
翻译 python官网对于dict字典操作的例子
Here is a small example using a dictionary:>>> tel = {'jack': 4098, 'sape': 4139}>>> tel['guido'] = 4127>>> tel{'sape': 4139, 'guido': 4127, 'jack': 4098}>>> te...
2018-04-26 15:10:43 257
原创 通过django的values_list和annotate实现group by功能
lnglat_set = LngLat.objects.all()heatmapdict = {}lnglat = lnglat_set.first()lnglat<LngLat: 126.03407000000,42.028320000000>celldatausage_set = CellDataUsage.objects.filter(cell__lnglat=lng...
2018-04-26 15:07:23 1669
翻译 values()和annotate()组合成group by 时,必须values再前,annotate在后,顺序不同则不起效果
values()¶Ordinarily, annotations are generated on a per-object basis - an annotatedQuerySet will return one result for each object in the originalQuerySet. However, when a values() clause is used to c...
2018-04-26 11:41:07 703
翻译 annotate与aggregate的区别
For example, to find the price range of books offered in each store,you could use the annotation:以下语句查的是每一个商店中书的最高价和最低价,注意是每一个商店,结果是按商店分的数组相当于给每条数据做注释。>>> from django.db.models import ...
2018-04-26 10:45:54 711 1
翻译 django group by (annotate), .values().annotate(), values( , ).distinct().annotate(Count())
An aggregate within a values() clause is applied before other argumentswithin the same values() clause. If you need to group by another value,add it to an earlier values() clause instead. For example:...
2018-04-26 10:18:37 2914
翻译 ManyToManyField增加的额外关系列,如何查询query
https://docs.djangoproject.com/en/2.0/topics/db/models/#extra-fields-on-many-to-many-relationshipsUnlike normal many-to-many fields, you can’t use add(), create(),or set() to create relationships:>...
2018-04-23 16:06:48 685
原创 ValueError: Cannot assign QuerySet :must be a instance
ValueError: Cannot assign "<QuerySet [<Poi: 1>]>": "ComplaintRelatedAmapPois.poi" must be a "Poi" instance.初学django数据库模型models,总是分不清楚QuerySet和instance实例,错过第二次,赶紧记住。注意:本意是想要一个instance实例,但是第...
2018-04-23 14:03:22 5847
原创 python写一个过滤日期时间的函数
使用re正则表达式过滤文字中日期时间的部分,groups()函数得到所有分组()年月日时分秒的结果,生成datetime日期。因为是从人工填写的文字中搜索日期,所以需要考虑的问题很多,比如:1、年份是2018年还是18年,whichyear函数专门解决这个问题,通过对比最长公共子序列,还可以解决年份位数有误的问题,比如20188或218.2、年份或月份不全的问题,如有年份没有月份,或有月份没有年份...
2018-04-22 12:08:29 2665
原创 python try except 出现异常时,except 中如何返回异常的信息字符串
https://docs.python.org/3/tutorial/errors.html#handling-exceptionshttps://docs.python.org/3/library/exceptions.html#ValueErrortry: int("x")except Exception as e: '''异常的父类,可以捕获所有的异常''' pri...
2018-04-20 17:29:33 8001
原创 python求下一个月的今天
https://docs.python.org/3/library/calendar.html?highlight=calendar#calendar.monthrangecalendar.monthrange(year, month)Returns weekday of first day of the month and number of days in month, for thespe...
2018-04-19 16:54:19 3721
原创 Model的一列数据,default=None与null=True,如果没有null=True,则不允许该数据为None,相当于default=None不起作用
# emos工单,投诉的内容class Record(models.Model): jobid = models.CharField(max_length=50, default=None) customerserviceid = models.BigIntegerField() city = models.ForeignKey(City, on_delete=models.C...
2018-04-17 17:33:00 4055
原创 如何使用try catch
以下时报错信息,最后一行有错误类型ValueError:Traceback (most recent call last): File "<input>", line 76, in <module> File "C:\Users\Administrator\PycharmProjects\first_django\first_app\db_opr.py", line 4...
2018-04-17 17:24:25 437
原创 python django中的时区问题 DateTimeField received a naive datetime while time zone support is active
遇到多条警告:C:\Users\Administrator\PycharmProjects\first_django\venv\lib\site-packages\django\db\models\fields\__init__.py:1423: RuntimeWarning: DateTimeField Record.whenoccur received a naive datetime (20...
2018-04-17 15:39:46 5447
原创 JavaScript splice胶接 的用法之一:删除数组中的指定元素
// 因为海量点是最后加入的图层,想要清除海量点,需要清除海量点的图层,// 方法:先将地图的所有图层取出到数组,将海量点图层弹出数组,再重设地图图层为去除海量点图层MassMarks的数组。var layers = map.getLayers();for (var i=0; i<layers.length; i++) { if ("AMap.MassMarks" === la...
2018-04-10 16:51:21 256
转载 python自动给数字前面补0的方法
python中有一个zfill方法用来给字符串前面补0,非常有用 view sourceprint?n = "123"s = n.zfill(5)asse...
2018-04-10 08:55:23 2002
原创 计算两个字符串的最长公共子串,找两个字符串的公共部分,如何在两个字符串中找出相同的字符串
代码:# 计算两个字符串的最长公共子串def getNumofCommonSubstr(str1, str2): lstr1 = len(str1) lstr2 = len(str2) record = [[0 for i in range(lstr2 + 1)] for j in range(lstr1 + 1)] # 多一位,为了在计算第一个字时,有个左上角的初始值...
2018-04-04 15:13:45 2105
转载 Python在方括号中使用for循环,类似[0 for i in range(10)],叫 列表解析List Comprehensions
https://www.cnblogs.com/liu-shuai/p/6098227.htmlPython 列表解析作者博文地址:https://www.cnblogs.com/liu-shuai/列表解析 根据已有列表,高效创建新列表的方式。 列表解析是Python迭代机制的一种应用,它常用于实现创建新的列表,因此用在[]中。语法: [expression for iter_val in...
2018-04-04 14:22:58 161900 3
翻译 filter()的参数内容,查找语句。其中in可以在一个结果集中查找是否包含另一个结果集的数据。
Field lookups¶Field lookups are how you specify the meat of an SQL WHERE clause. They’re specified as keyword arguments to the QuerySet methods filter(), exclude() and get().For an introduction, see m...
2018-04-03 10:52:23 4091
翻译 count专门输出查询结果集的数量,比len()快,count不需要将数据从数据库提取到内存。
count()¶count()¶Returns an integer representing the number of objects in the database matchingthe QuerySet. The count() method never raises exceptions.Example:# Returns the total number of entries in ...
2018-04-03 10:47:22 1080
翻译 exists的作用是反馈查询结果集是否为空,速度快。
exists()¶exists()¶Returns True if the QuerySet contains any results, and Falseif not. This tries to perform the query in the simplest and fastest waypossible, but it does execute nearly the same query...
2018-04-03 10:43:15 741
翻译 django以字典或元组形式输出数据库结果集,可以选择输出特定列的结果
values()¶values(*fields, **expressions)¶Returns a QuerySet that returns dictionaries, rather than model instances, when used as an iterable.Each of those dictionaries represents an object, with the ke...
2018-04-03 10:32:57 2862
CitrixReceiver组件ICAWebWrapper.msi
2018-11-27
OMC北向接口参数说明
2018-09-28
3GPP CORBA Alarm IRP 协议原文
2018-09-28
datang CORBA .idl文件
2018-09-28
"com.zznode.tnms.ra.c11n.nj.resource.ftp.UnixFTPEntryParser"
2018-06-25
jfreechart-1.0.19-demo-src
2017-11-07
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人