手机
当前位置:查字典教程网 >脚本专栏 >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 zip文件 压缩

Python 文件重命名工具代码

Python 的 with 语句详解

Python ljust rjust center输出

Python 文件和输入输出小结

python字符串加密解密的三种方法分享(base64 win32com)

学习python (1)

Python字符转换

python单链表实现代码实例

Python 命令行非阻塞输入的小例子

精品推荐
分类导航