本文摘自php中文网,作者coldplay.xixi,侵删。

python两列字符串如何合并?
python两列字符串合并的方法:
1、在很多情况下,我们都需要合并字符串。例如:需要将姓氏与名字存储在不同的变量中,然后显示的时候再将他们合二为一
1 2 3 4 | first_name = 'oliver'
last_name = 'smith'
full_name = first_name + ' ' + last_name
print (full_name)
|
打印结果:
oliver smith
2、python中使用(+)号来合并字符串
这种字符串合并的方法称为拼接,可使用存储在变量中的信息来创建完整的信息
1 2 3 4 | first_name = 'oliver'
last_name = 'smith'
full_name = first_name + ' ' + last_name
print ( 'Hello ' + full_name.title() + '!' )
|
打印结果:
阅读剩余部分
相关阅读 >>
为什么用Python写网页
如何用Python计算圆周率?
Python数值类型有哪些
爬虫&问题解决&思考
Python中什么是语句块?
Python如何转换时间戳
Python序列基础--元组
Python用途广泛么
Python获取程序执行文件路径的方法
Python如何安装whl文件
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » python两列字符串如何合并?