def strTest():
name = ""
for i in range(10):
name +=
"hello"
#print name
def strTest2():
nameList =
["hello","hello","hello","hello","hello","hello","hello","hello","hello","hello"]
name = "".join(nameList)
#print name
if __name__ ==
"__main__":
import timeit
t = timeit.Timer("strTest()","from
__main__ import strTest")
t2 = timeit.Timer("strTest2()","from __main__
import strTest2")
print t.timeit()
print t2.timeit()
相关文章
- 11-18python基础操作---string
- 11-18一个喜剧简单的python程序上的IRC连接错误
- 11-18【LeetCode】606. Construct String from Binary Tree 解题报告(Python)
- 11-18【Python实战】使用Python连接Teradata数据库???未完成
- 11-18python – 有没有办法在Robot Framework的ssh连接中使用telnet?
- 11-18【LeetCode】87. Scramble String 解题报告(Python & C++)
- 11-18吴裕雄--天生自然python学习笔记:python 建立 Firebase 数据库连接
- 11-18", line 1, in
NameError: name 'f' is not defined">Python2 错误记录1File " ", line 1, in NameError: name 'f' is not defined - 11-18python 基于udp 连接
- 11-18python-没有空闲子进程连接