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()

python string 连接test的更多相关文章

  1. python string

    string比较连接 >>> s1="python string" >>> len(s) 13 >>> s2=" p ...

  2. Python string interning原理

    原文链接:The internals of Python string interning 由于本人能力有限,如有翻译出错的,望指明. 这篇文章是讲Python string interning是如何 ...

  3. 【Azure Developer】使用 Python SDK连接Azure Storage Account, 计算Blob大小代码示例

    问题描述 在微软云环境中,使用python SDK连接存储账号(Storage Account)需要计算Blob大小?虽然Azure提供了一个专用工具Azure Storage Explorer可以统 ...

  4. 关于python字符串连接的操作

    python字符串连接的N种方式 注:本文转自http://www.cnblogs.com/dream397/p/3925436.html 这是一篇不错的文章 故转 python中有很多字符串连接方式 ...

  5. python string module

    String模块中的常量 >>> import string >>> string.digits ' >>> string.letters 'ab ...

  6. python 字符串连接

    字符串连接 方法1: 用字符串的join方法 a = ['a','b','c','d']content = ''content = ''.join(a)print content 方法2: 用字符串的 ...

  7. The internals of Python string interning

    JUNE 28TH, 2014Tweet This article describes how Python string interning works in CPython 2.7.7. A fe ...

  8. Python string objects implementation

    http://www.laurentluce.com/posts/python-string-objects-implementation/ Python string objects impleme ...

  9. 使用Python编程语言连接MySQL数据库代码

    使用Python编程语言连接MySQL数据库代码,跟大家分享一下: 前几天我用python操作了mysql的数据库,发现非常的有趣,而且python操作mysql的方法非常的简单和快速,所以我把代码分 ...

随机推荐

  1. 字符串转与ASCII码之间的互换

    1.字符串转换成ASCII码 public static String stringToAscii(String value) { StringBuffer sbu = new StringBuffe ...

  2. TreeView递归取值

    string jingyuan = ""; string jinghui = ""; private void DiGui(TreeNode tn) { if ...

  3. 【原】隐藏ultraGrid1指定列

    void uGrdAllFlight_InitializeRow(object sender, InitializeRowEventArgs e) { /***********TEST START** ...

  4. mac下安装redis

    安装php_redis.so 首先用git从https://github.com/nicolasff/phpredis下载源码.然后依次执行以下命令 sudo /Applications/XAMPP/ ...

  5. 用python实现了一下:甲乙两人互猜数字(数理逻辑)

    今天在园子里看到博客:超难面试题:甲乙两人互猜数字(数理逻辑).然后琢磨了半天,写了个Python程序实现算法,我得出来的结果是1,6或1,8或35,42的组合, 不知道是否正确,请高人指点? 下面列 ...

  6. python字典操作

    Python字典是另一种可变容器模型,且可存储任意类型对象,如字符串.数字.元组等其他容器模型.一.创建字典字典由键和对应值成对组成.字典也被称作关联数组或哈希表.基本语法如下: 代码如下: dict ...

  7. Ping的过程详解

    先看拓朴图: 我在这里讲拼的两情况,一种是同一网段内,一种是跨网段的ping …. 首先,如果主机A,要去拼主机B,那么主机A,就要封装二层报文,他会先查自己的MAC地址表,如果没有B的MAC地址,就 ...

  8. uva401 - Palindromes结题报告

    题目地址 :  http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_probl ...

  9. 1048. Find Coins (25)

    时间限制 50 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Eva loves to collect coins from a ...

  10. JavaScript console 用法大全

    对于前端开发者来说,在开发过程中需要监控某些表达式或变量的值的时候,用 debugger 会显得过于笨重,取而代之则是会将值输出到控制台上方便调试.最常用的语句就是console.log(expres ...