加载中
Python Linked-list

双向链表

2017/11/24 15:33
126
nginx bind() to 0.0.0.0:**** failed (13: Permission denied) 解决方案

nginx 启动失败,日志里面报错信息如下: Starting nginx: nginx: [emerg] bind() to 0.0.0.0:**** failed (13: Permission denied) 权限拒绝,经检查发现是开启selinux 导致的。 getenforce 这...

2017/11/20 14:22
2.5K
Linux & Shell 重定向输出

将脚本中的输出全部定向到文件: 每次输出将输出覆盖到文本: echo ‘1’ > log.txt 每次输出将追加至文本末尾: echo ‘1’ >> log.txt 实例: 比如我有一个脚本 1.py For I in range(10):...

2017/11/20 14:18
34
Python3 Sorted() 用法

Signature: sorted(iterable, /, *, key=None, reverse=False) Docstring: Return a new list containing all items from the iterable in ascending order. *返回一个排序后的list A custom...

2017/10/17 17:34
190
给出一个序列的指定长度的所有子序列

给出一个序列的指定长度的所有子序列,例如序列{1,2,3,4,5,6,7,8},长度为3的子序列为{1,2,3},{1,2,4},{1,2,5},...,{2,3,4},{2,3,5},{2,3,6},...,{6,7,8}。...

2017/08/31 23:01
2.1K
flask-login 实例

BluePrint: (auth.py) # coding: utf-8 from flask import request, render_template, redirect, Blueprint, url_for from flask_login import LoginManager, login_user, UserMixin, log...

2017/07/23 00:05
720
Redis 高效插入大量数据

管道(pipeline)是redis在提供单个请求中缓冲多条服务器命令的基类的子类。 它通过减少服务器-客户端之间反复的TCP数据库包,从而大大提高了执行批量命令的功能 import redis r = redis...

2017/05/16 19:54
218
解包/分解/展开 list 的两种方式

#coding : utf-8 def unpack_list(s): """将list转为字符串 替换所有'['和']',最后用eval来生成新的list""" return eval('[{}]'.format(str(s).replace('[','').replace(']',''))...

2017/05/02 23:03
574
正则表达式的贪婪和非贪婪模式

> s = '(1,2,3) - (4,5,6)' > re.findall('\(.*\)',s) > ['(1,2,3) - (4,5,6)'] > re.findall('\(.*?\)',s) > ['(1,2,3)', '(4,5,6)'] 如上图,第一次直接使用 \(.*\) 去搜索字符串时,右...

2017/04/25 10:53
253
Python 中直接忽略异常的用法

try: doSomething() except: pass 或 try: doSomething() except Exception: pass 区别在于,第一种也会捕捉到 KeyboardInterrupt, SystemExit之类,它直接来自 exceptions.Bas...

2017/04/02 11:13
386
Python 单例模式

""" Python 单例模式测试 """ class Dog: def __init__(self): print('init dog!') class A: __dog = None def __init__(self): self.__dog =...

2017/02/21 18:29
16
Python3 线程池 ThreadPoolExecutor

# coding: utf-8 import threading import time from concurrent.futures import ThreadPoolExecutor def test(): for i in range(5): print('running thread id : %d now=%...

2017/02/21 18:09
2.5K
pip3 安装gunicorn后,运行提示无法找到命令时的解决方法

问题: 同时安装了python2与python3 再安装 pip3 install gunicorn 然后使用 gunicorn 会提示 command not found 在StackOverFlow上找到一个替代方案: 将下面的run_gunicorn脚本拷贝到main....

2017/02/13 22:52
5.8K
Flask 装饰器问题 AssertionError: expected view func if endpoint is not provided.

Flask下使用装饰器,提示错误 AssertionError: expected view func if endpoint is not provided. 详见: http://flask.pocoo.org/docs/0.12/patterns/viewdecorators/ 修改: 必须使用funct...

2017/01/22 21:08
1K
理解 Python中的装饰器

#什么是装饰器? Python这个语言是可以直接传递函数的: 比如: def pr(func): func() def foo(): print('ok') pr(foo) 那么简单来说,装饰器的行为就是将被装饰函数传递给装饰器函...

2017/01/17 18:00
148
Python3 sort and sorted

Python lists have a built-in list.sort() method that modifies the list in-place. There is also a sorted() built-in function that builds a new sorted list from an iterable. list类...

2017/01/10 02:11
30

没有更多内容

加载失败,请刷新页面

返回顶部
顶部