加载中
Python Linked-list

双向链表

2017/11/24 15:33
94
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 这...

Linux & Shell 重定向输出

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

2017/11/20 14:18
56
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...

给出一个序列的指定长度的所有子序列

给出一个序列的指定长度的所有子序列,例如序列{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
595
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
320
Redis 高效插入大量数据

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

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

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

2017/05/02 23:03
200
Python 俄罗斯方块

GIT传送门: http://git.oschina.net/codetimer/eluosifangkuai

正则表达式的贪婪和非贪婪模式

> 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
93
Code Like a Pythonista: Idiomatic Python

Code Like a Pythonista: Idiomatic Python David Goodger goodger@python.org http://python.net/~goodger In this interactive tutorial, we'll cover many essential Python idioms and t...

Python 中直接忽略异常的用法

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

Python 单例模式

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

2017/02/21 18:29
55
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
741
pip3 安装gunicorn后,运行提示无法找到命令时的解决方法

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

linux 编译安装 Python3.6 (保留自带Python2)

yum install wget yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel cd /usr/local/src wget https://www.python.org/ftp/python/3...

2017/02/02 22:20
763
关于x64系统内的重定向文件夹 SysWow64

32 位程序获取 system32 目录时会转向SysWow64 也就是说,虽然你打开文件指明路径是 system32,但实际上打开的是 SysWoW64 下的对应文件 这个需要用到这几个 API 来控制是否进行重定向: Wo...

2017/02/01 00:55
171
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...

理解 Python中的装饰器

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

2017/01/17 18:00
87
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类...

没有更多内容

加载失败,请刷新页面

返回顶部
顶部