python 3, 字符串连接速度
来源:互联网 发布:知乎付费问答 编辑:程序博客网 时间:2024/06/05 18:36
对比字符串连接速度,可以发现, 字符串少时, +快;
字符串多时, join快
from time import timedef method1(): t = time() for i in range(100000): s = 'hiweeds'+'hiweeds'+'hiweeds'+'hiweeds'+'hiweeds'+'hiweeds'+'hiweeds'+'hiweeds'+'hiweeds'+'hiweeds' t1 = time() print ("Time %f" % (t1 - t))def method2(): t = time() for i in range(100000): s = ''.join(['hiweeds','hiweeds','hiweeds','hiweeds','hiweeds','hiweeds','hiweeds','hiweeds','hiweeds','hiweeds']) print (time() - t)print ('hello World')method1()method2()def method3(): t = time() for i in range(100000): s = 'hiweeds'+'hiweeds'+'hiweeds'+'hiweeds' t1 = time() print ("Time %f" % (t1 - t))def method4(): t = time() for i in range(100000): s = ''.join(['hiweeds','hiweeds','hiweeds','hiweeds']) print (time() - t)print ('hello World')method3()method4()
0 0
- python 3, 字符串连接速度
- python字符串拼接速度对比
- python字符串连接
- python------字符串连接操作
- python 中的字符串连接
- python中的字符串连接
- python字符串连接
- Python字符串连接
- python字符串连接方法
- python的字符串连接
- Python join() 函数 连接字符串
- python 字符串与变量连接
- python字符串连接方式汇总
- python连接两个字符串切片
- Python 连接数据库&切割字符串
- Learning Python 026 字符串连接
- Python字符串连接方式小结
- python字符串连接与截取
- CentOS 7.0 systemctl使用说明
- c++学习之OO思想
- 深拷贝与浅拷贝
- Android PopupWindow显示在控件上方或者下方
- 抽屉效果实现原理
- python 3, 字符串连接速度
- Debian和Ubuntu的root用户
- android 守护线程Daemon解说
- 交换机端口汇聚
- 计算机网络实验之二层交换机实验
- ubuntu14.04 LTS DeskTop 安装 skyeye-1.3.3
- 黑马程序员_JavaSE基础知识总结二:结构和语句
- 文件读写
- iptables 使用总结