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. 对C#调用C++ dll文件进行总结

    在实际项目工作中,经常用到C#调用C++ 或者C编写的dll文件. dll支持一般函数声明和类的定义声明,但是一般为了简化,都是 采用函数声明的方式.这里主要并不是写 dll的编写. 先在vs中创建一 ...

  2. 导出excel表格

    一. 1.获取数据源2.DataTable dt = st.Tables[0]; HttpResponse resp; // HTTP响应信息 resp = Page.Response; resp.C ...

  3. CSS3.0动画之hover---Y轴----3D旋转

    div#div2{display: table; width: 100%; height: 100%; text-decoration: none; outline: none; -webkit-tr ...

  4. Review PHP设计模式之——单例模式

    单例模式: class Single { private static $_instance; private function __construct(){ //define method as p ...

  5. 【DELPHI】线程相关

    //准备让线程调用的测试函数 procedure Draw(aCanvas: TCanvas; X,Y: Integer; aCount: Integer = 100000); var i: Inte ...

  6. 【转】 GDB 常用调试方法

    一.多线程调试 多线程调试可能是问得最多的.其实,重要就是下面几个命令: info thread 查看当前进程的线程. thread <ID> 切换调试的线程为指定ID的线程. break ...

  7. shell 实现类似php的require_once函数

    config.sh #/bin/bash require_once() { #File the true path ,To prevent a symbolic link local realpath ...

  8. EasyUI Layout Full - Not Correct in IE8

    EasyUI Full布局在IE10,IE9下正常,IE8无效果,标记一下有知道的可以留个言! 如图 IE 10 IE 8

  9. 【tyvj1860】后缀数组

    描述 我们定义一个字符串的后缀suffix(i)表示从s[i]到s[length(s)]这段子串.后缀数组(Suffix array)SA[i]中存放着一个排列,满足suffix(sa[i])< ...

  10. python学习笔记4(列表)

    列表是最通用的Python复合数据类型,列表中包含以逗号分隔,并在方括号([])包含的项目. 在一定程度上,列表相似C语言中的数组,它们之间的一个区别是,所有属于一个列表中的项目可以是不同的数据类型的 ...