本文摘自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生成mac地址
编程Python是什么
Python 解决中文写入excel时抛异常的问题
Python中property函数的用法
Python什么时候出现的
Python网络爬虫步骤是什么
Python爬虫如何设置代理
详解Python中for循环的工作原理
Python set函数是什么
Python中数据预处理(代码)
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » python两列字符串如何合并?