This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
from thread import start_new_thread | |
X =1 | |
def worker(): | |
while 1: | |
global X | |
X *= 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dst | |
import a_1 # 1不能直接做变量,所以import 1是不行的。 | |
import b_2 | |
# 这里分两种情况,a_1中有一个主函数main,则运行main,如果没有主函数,a_1中直接就是逻辑代码,那么不需要运行任何东西,import a_1的时候,a_1的代码就会直接运行 | |
a_1.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> def a(): | |
... s = time.time() | |
... for i in xrange(0, 100000000): | |
... pass | |
... print time.time() -s | |
... | |
>>> def b(): | |
... s = time.time() | |
... i = 0 | |
... while i < 100000000: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getMaxpage(): | |
page=2 | |
dir_url="http://aa.wordpress.com/2013/06/page/"+str(page) | |
while getPageFlag(dir_url): | |
page=page+1 | |
dir_url="http://fashioncoolture.com.br/2013/06/page/"+str(page)#这个要更新的 | |
print page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def a(l): | |
c, n = l[-1] - l[-2], 0 | |
r = len(l) -2 | |
while n <= len(l) -3: | |
cc = l[n+1] - l[n] | |
if cc < c: | |
r, c = n, cc | |
n = n +1 | |
return r, r+1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# encoding: utf-8 | |
class Foo(object): | |
def __init__(self): | |
self._func = None | |
def callDerivedFunc(self): | |
self._func() # wrong #这里实际上等于:Bar.hello(), hello是一个实例方法,需要传递一个实例才能调用。所以报错,应该改成:self._func(self) | |
method = self._func |