b import 了 a, c import 了 b,c 中也会有定义test.py 1 __all__ = ['a', 'b'] 2 3 def a(): 4 print "a" 5 6 def b(): 7 print "b" 8 9 def c():10 prin...
分类:
编程语言 时间:
2014-09-10 09:33:00
阅读次数:
204
首先我们通过网友在stackoverflow关于python super类的一个疑问来作为本篇的开始,问题大致是这样的:>>> class A(object):... def __init__(self):... print "A init"... ...
分类:
编程语言 时间:
2014-09-09 17:33:59
阅读次数:
189
python判断网站来自手机还是pc浏览器 #判断网站来自mobile还是pc
def?checkMobile(request):
????"""
????demo?:
????????@app.route(‘/m‘)
????????def?is_from_mobile():
?????...
分类:
移动开发 时间:
2014-09-09 16:23:19
阅读次数:
341
就是计算一个数的阶乘。
0
跟笔算一个样子。每一位用数组去存就好了。
我的挫代码:500+ms
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define INF 0x7fffffff
#define eps 1e-8
#def...
分类:
其他好文 时间:
2014-09-09 12:35:18
阅读次数:
250
python里一个class可以定义多个构造函数吗?实现方法:class A: def __init__(self, value): if isinstance(value, int): #整型构造函数 else ifinstance(valu...
分类:
编程语言 时间:
2014-09-09 10:56:28
阅读次数:
183
用Qt写了两个多月的gui界面了,居然连怎么起头都单独写不出来了。。。惭愧from PyQt4 import QtGui,QtCoreclass MainWindow(QtGui.QMainWindow): def __init__(self): super (MainWindo...
分类:
其他好文 时间:
2014-09-09 10:49:38
阅读次数:
215
本篇将讨论gevent的两架马车-libev和greenlet如何协同工作的。gevent事件驱动底层使用了libev,我们先看看如何单独使用gevent中的事件循环。#coding=utf8
import socket
import gevent
from gevent.core import loop
def f():
s, address = sock.accept()
p...
分类:
其他好文 时间:
2014-09-08 01:04:46
阅读次数:
396
1.the concept of List2. how to define a method of myself3.how to iterator a listPS:for Step 2,3. it is related with a key word: 'def'. we define a fun...
分类:
编程语言 时间:
2014-09-07 21:00:15
阅读次数:
229
题意:给定4个长度为N的字符串( N 2 #pragma comment(linker, "/STACK:102400000,102400000") 3 #define in freopen("F:\\rootial\\data\\data.txt", "r", stdin); 4 #def...
分类:
其他好文 时间:
2014-09-07 19:47:45
阅读次数:
288
def funcname(param1,param2,...): statements在函数中没有与全局变量同名的变量时,我们可以直接读取全局变量的值(不提倡这么做,容易混淆)要想在函数内对全局变量进行重新赋值,就得在函数内使用global语句e.g.number = 23def assignnu....
分类:
编程语言 时间:
2014-09-07 12:19:05
阅读次数:
229