手机
当前位置:查字典教程网 >脚本专栏 >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字符串加密解密的三种方法分享(base64 win32com)

Python去掉字符串中空格的方法

Python 的 with 语句详解

python笔记(1) 关于我们应不应该继续学习python

python 自动提交和抓取网页

python getopt 参数处理小示例

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

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

精品推荐
分类导航