python 字符串连接 小知识点 -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【www.unjs.com - 电脑资料】

    python字符串常用连接的方法:

    1.使用“+”连接:

    blog = 'linuxinge' + '.blog' + '.51cto' + '.com'

    print blog

   

    2.使用join

    blog =[ 'linuxinge','.blog' , '.51cto' , '.com']

    print ''.join(blog)

    3.使用字符串格式化:

    print '%s%s%s%s' % ( 'linuxinge','.blog' , '.51cto' , '.com')

最新文章