摘要: #coding=utf-8 from multiprocessing import Pool import os, time, random def run_task(name): print 'Task %s (pid = %s) is running...' % (name, os.getpid()) time.sleep(random.random() * 5) ... 阅读全文
posted @ 2018-11-19 11:47 道高一尺 阅读(388) 评论(0) 推荐(0) 编辑
摘要: ubuntu系统下,运行一个django项目,即输入python manage.py runserver后,可能出现 Error: That port is already in use.的错误。 即端口号已经被占用,说明servr已经在运行了(也有可能在后台运行) 那么找到该进程,kill掉即可. 或者最简单的解决方法就是: 在终端输入 sudo fuser -k 8000/tcp ... 阅读全文
posted @ 2018-10-10 10:35 道高一尺 阅读(1276) 评论(0) 推荐(0) 编辑
摘要: 1、运行django的指令:python manage.py runserver 2、创建项目 django-admin.py startproject mesite 3、创建应用 django-admin.py startapp blog 4、注册应用 settings INSTALLED_APPS 5、根据数据库模型建立数据库表文件(相当于生成sql语句) python mana... 阅读全文
posted @ 2018-09-19 13:47 道高一尺 阅读(201) 评论(0) 推荐(0) 编辑
摘要: >>> class A(object): bar = 1 def func1(self): print 'foo' >>> class A(object): bar = 1 def func1(self): print 'foo' @classmethod def func2(cls): ... 阅读全文
posted @ 2018-09-13 13:57 道高一尺 阅读(277) 评论(0) 推荐(0) 编辑
摘要: class Test(object): def __init__(self, value='hello, world!'): self.data = value >>> t = Test() >>> t >>> print t # 看到了么?上面打印类对象并不是很友好,显示的是对象的内存地址 # 下面我们重构下该类的__repr__以及__str__,看看它们俩有... 阅读全文
posted @ 2018-09-10 15:11 道高一尺 阅读(231) 评论(0) 推荐(0) 编辑
摘要: #coding=utf-8 import re import time import json import requests from selenium import webdriver from selenium.common.exceptions import TimeoutException from selenium.webdriver.common.by import By fro... 阅读全文
posted @ 2018-09-05 10:14 道高一尺 阅读(508) 评论(0) 推荐(0) 编辑
摘要: BootStrap 大家好 同志们辛苦了 --> 为人民服务 p默认定义文字大小为1... 阅读全文
posted @ 2018-08-29 09:50 道高一尺 阅读(205) 评论(0) 推荐(0) 编辑
摘要: >>> from timeit import Timer >>> Timer("temp = x; x = y; y = temp", "x = 2; y = 3").timeit() 0.04535215532074004 >>> Timer("x, y = y, x", "x = 2; y = 3").timeit() 0.06476211600816484 阅读全文
posted @ 2018-08-27 09:29 道高一尺 阅读(286) 评论(0) 推荐(0) 编辑
摘要: >>> x = 1 >>> y = 2 >>> assert x == y, "not equals" Traceback (most recent call last): File "", line 1, in assert x == y, "not equals" AssertionError: not equals >>> 阅读全文
posted @ 2018-08-27 09:13 道高一尺 阅读(176) 评论(0) 推荐(0) 编辑
摘要: Title 阅读全文
posted @ 2018-08-16 21:22 道高一尺 阅读(3452) 评论(0) 推荐(0) 编辑