浅析Python中的join()方法的使用,pythonjoin
浅析Python中的join()方法的使用,pythonjoin
join()方法方法返回一个在序列的字符串元素被加入了由str分隔的字符串。
语法
以下是join()方法的语法:
str.join(sequence)
参数
- sequence -- 这是要连接的元素的顺序。
返回值
此方法返回一个字符串,在序列seq字符串的连接。元素之间的分离器是字符串 str。
例子
下面的示例演示了join()方法的使用。
#!/usr/bin/python str = "-"; seq = ("a", "b", "c"); # This is sequence of strings. print str.join( seq );
当我们运行上面的程序,它会产生以下结果:
a-b-c
相关内容
- 在Python中处理字符串之ljust()方法的使用简介,pythonlj
- Python中用于转换字母为小写的lower()方法使用简介,py
- Python中的lstrip()方法使用简介,pythonlstrip
- Python2.x版本中maketrans()方法的使用介绍,python2.xmaketra
- 在Python中操作字符串之replace()方法的使用,pythonreplac
- Python中的rfind()方法使用详解,pythonrfind
- Python3.2中Print函数用法实例详解,python3.2print
- 用Python操作字符串之rindex()方法的使用,pythonrindex
- Python中random模块用法实例分析,pythonrandom
- Python递归遍历列表及输出的实现方法,python递归遍输出
评论关闭