One - One Code All

Blog Content

python连接字符串的三种方法

Python   2008-08-05 21:05:59

python字符串连接的方法,一般有以下三种:

方法1:直接通过加号(+)操作符连接: 效率比较低。
    
str = 'python'  + '.com'

方法2:join方法:多字符串连接效率高
    
list_str = ['python','.com']
str = ''.join(list_str)

方法3:替换: 字符串格式化
    
str = '%s%s' % ('python', .com')



上一篇:Linux关机命令详解
下一篇:python简明教程001-python特色

The minute you think of giving up, think of the reason why you held on so long.