- 博客(20)
- 资源 (5)
- 收藏
- 关注
原创 Codility编程课一 Find unpaired element
Task descriptionA non-empty array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the sam...
2018-07-31 23:05:57 539
原创 Codility编程课一 Array Rotation
Task descriptionAn array A consisting of N integers is given. Rotation of the array means that each element is shifted right by one index, and the last element of the array is moved to the first pla...
2018-07-31 20:11:48 706 1
原创 Codility编程课一binary gap
Task descriptionA binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N.For example, number ...
2018-07-31 19:53:28 610
原创 python 使用xlsxwriter 实现有向无环图到Excel的转换
本程序假定有向无环图已经存在def generate_excel(dag, row_start,col_start,excel_file):#参数分别为有向无环图图、开始写入的行,开始写入列,以及文件名 import xlsxwriter#导入Excel操作模块 workbook = xlsxwriter.Workbook(excel_file)#创建Excel文件 w...
2018-07-27 21:51:59 439
原创 Python implementation of directed acyclic graph(python实现的有向无环图)
Python implementation of directed acyclic graph(python实现的有向无环图)关于此实现可以在GitHub上找到开源模块缘由:项目中用到了dag来表示某个数据分析的结果,然后需要转换成Excel来显示(此话题将在下一篇博客中) 然后又要将Excel内容以原样展示到网页中(此话题将在下下一篇博客中) python实现此数据结构的时候...
2018-07-27 21:15:03 1289
原创 结合pandas.DataFrame.any与pandas.DataFrame.drop删除DataFrame中非真的行或者列
首先把官网的用法过一遍1、DataFrame.any(axis=0, bool_only=None, skipna=True, level=None, **kwargs)Return whether any element is True over requested axis.只要选中的维度中有一个真值则返回真>>> df = pd.DataFrame({"A"...
2018-07-26 21:06:38 1843
转载 Django Model Meta options
为Model设置元数据的时候只需要在Model类内部写一个元类然后添加需要的参数:基础实例如下:from django.db import modelsclass Ox(models.Model): horn_length = models.IntegerField() class Meta: ordering = ["horn_length"] ...
2018-07-19 18:02:41 733 1
原创 Django Model ForeignKey.on_delete=models.CASCADE
首先我们来熟悉一下Django Model中外键的定义方式:class ForeignKey(to, on_delete, **options)A many-to-one relationship. Requires two positional arguments: the class to which the model is related and the on_delete op...
2018-07-19 15:46:58 3550 3
原创 Django QuerySet attributes之order_by()基础用法以及如何传递打包排序参数
本文分为两部分:官网相关部分文档展示如何向order_by传递打包排序参数【项目中的实际使用情景】官网相关部分文档官网文档中的用法只涉及一般用法,适用于参数固定或者静态参情景,对于动态构造后面我会进行补充order_by(*fields)¶By default, results returned by a QuerySet are ordered by the order...
2018-07-18 17:57:55 17837
转载 Python XlsxWriter module 使用之单元格合并 worksheet.merge_range()
merge_range(first_row, first_col, last_row, last_col, data[, cell_format]) Merge a range of cells.Parameters: first_row (int) – The first row of the range. (All zero indexed.)first_col (int) – T...
2018-07-11 17:29:37 25469 3
转载 Python XlsxWriter module 使用之列求和
求和示例数据如下:expenses = ( ['Rent', 1000], ['Gas', 100], ['Food', 300], ['Gym', 50],)操作代码如下:>>> import xlsxwriter>>> workbook = xlsxwriter.Workbook('demo....
2018-07-11 10:06:36 1843 2
转载 pandas.DataFrame
官方文档入口class pandas.DataFrame(data=None, index=None, columns=None, dtype=None, copy=False) 数据除了可以直接传递对象外还有以下几个来源:DataFrame.from_records constructor from tuples, also record arraysDataFrame....
2018-07-10 20:23:38 651
原创 django应用代码性能分析
以下三种执行方式的速度/性能排列是怎么样的,请分析:suppose we have a model named Bicycle and we want to get bicycles which belongs to lockey23. Firstly, we have some code as below:my_bicycles = Bicycle.objects.filter(user...
2018-07-08 12:46:10 365
原创 CSS3的nth-child() 选择器
nth-child()浏览器支持IE9及以上版本,火狐,谷歌,Safari ,Opera都支持!:nth-child(n) 选择器匹配属于其父元素的第 n个子元素,不论元素的类型。n 可以是数字、关键词或公式。p:nth-child(2)/*将匹配body的第二个元素*/{background:#ff0000;}不要把:nth-child() 和:nth-of-type...
2018-07-04 22:25:55 353
转载 Encrypted MySQL Connections
This week I fought with MySQL trying to get an encrypted connection. Getting the server piece to appear to work was easier than actually getting the connection. Whether the problems didn’t show up unt...
2018-07-04 18:52:17 893
原创 How to enable SSL/TLS for MySQL server and client(如何设置MySQL服务器和客户端加密传输以及对应Django应用的设置)
首先看一下服务器版本,如果不同版本请自行迁移ubuntu 16.04 visit hereServer version: 5.6.19-0ubuntu0.14.04.1 (Ubuntu)mysql> status--------------mysql Ver 14.14 Distrib 5.6.19, for debian-linux-gnu (x86_64) using ...
2018-07-04 18:45:12 1538 1
原创 django 应用中获取访问者ip地址
在django官方文档中有一段对request.META的解释:HttpRequest.METAA standard Python dictionary containing all available HTTP headers. Available headers depend on the clientand server, but here are some examples:...
2018-07-03 19:55:16 10872 1
原创 为Django应用添加logging日志功能
Django uses Python’s builtin logging module to perform system logging. Django使用python的内建日志模块来记录系统日志,但是要想在django应用中开启此功能使我们的部分操作能够被记录到日志文件,那么就需要进行一定的配置并且根据具体的log类型来进行调用step 1:配置setting.py以下配置除了fi...
2018-07-03 19:36:56 3748
原创 Django设置 DEBUG = False后静态文件无法加载解决
问题出现的原因:当我们在开发django应用时如果设置了 DEBUG = True,那么django便会自动帮我们对静态文件进行路由;但是当我们设置DEBUG = False后,这一功能便没有了,此时静态文件就会出现加载失败的情况,想要让静态文件正常显示,我们就需要配置静态文件服务了。配置静态文件服务一般有两种情况,一种是使用文件服务器如nginx来实现:location /stat...
2018-07-02 15:19:54 4520
原创 经济学人(The Economist)阅时即查应用 V4版本发布公测
第四个版本计划了有一个月了,但是因为工作忙、新版设计未定、懒等原因前天晚上才动工开始做,其实效率还算很高的,毕竟只不过用了两天时间,但是却完成了完全的改版,使用过上一版本的同学应该会有很深体会的新版本设计亮点如下**所有板块以nav的形式来进行切换文章分页做了很大改进增加了每日格言整体的style改变也很明显,pc和mobile的兼容有了很好提升个人相关链接的布局改变等。。...
2018-07-01 18:07:43 692
saltstack安装rpm包以及依赖(rhel65)
2017-10-13
Python3.6.2
2017-09-02
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人