本文共 1595 字,大约阅读时间需要 5 分钟。
#!/usr/bin/env python #coding=utf-8 import time def check(num): a = list(str(num)) b = a[::-1] if a == b: return True return False def (): all = xrange(1,10**7) for i in all: if check(i): if check(i**2): i**2 if __name__ == '__main__': start=time.time() test() print time.time()-start 分别用python和pypy的运行结果 C:\Python27\python.exeD:/RCC/mp/src/test.py 14.4940001965 C:\pypy-2.1\pypy.exeD:/RCC/mp/src/test.py 4.37800002098 |