黑客防线,在攻与防的对立统一中寻求突破!2001年创刊的黑客技术专业刊物!

设为首页
收藏本站
联系我们
网站导航

黑客文章 - 黑客编程 - 浏览 - Python天天美味(7) - 连接字符串(join %)

Python天天美味(7) - 连接字符串(join %)

黑客 发布日期:2008-8-18 0:11:28 共有 254 人次浏览
Python天天美味(7) - 连接字符串(join %)
join 方法用于连接字符串数组
s = ['a', 'b', 'c', 'd']
print ''.join(s)
print '-'.join(s)
输出结果:
abcd
a-b-c-d

使用 % 连接多个变量
a = 'hello'
b = 'python'
c = 1
print '%s %s %s %s' % (a, b, c, s)
输出结果:
hello python 1 ['a', 'b', 'c', 'd']
所属分类: 黑客编程     网摘收藏: Google 雅虎 百度 POCO 365key 和讯 天极