手机
当前位置:查字典教程网 >脚本专栏 >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 命令行非阻塞输入的小例子

学习python (1)

python连接mysql并提交mysql事务示例

Python学习资料

Python 文件重命名工具代码

Python ljust rjust center输出

简明 Python 基础学习教程

python实现的各种排序算法代码

Python字符转换

精品推荐
分类导航