手机
当前位置:查字典教程网 >脚本专栏 >python >Python 连接字符串(join %)
Python 连接字符串(join %)
摘要:join方法用于连接字符串数组复制代码代码如下:s=['a','b','c','d']print''.join(s)print'-'.joi...

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']

【Python 连接字符串(join %)】相关文章:

Python字符遍历的艺术

Python ljust rjust center输出

python 实现归并排序算法

python 自动提交和抓取网页

python使用正则搜索字符串或文件中的浮点数代码实例

Python 文件和输入输出小结

Python 流程控制实例代码

python单链表实现代码实例

Python open读写文件实现脚本

python zip文件 压缩

精品推荐
分类导航