Python字符串拼接的几种方法整理
作者:Godliness丶 时间:2021-05-08 18:55:47
Python字符串拼接的几种方法整理
第一种 通过加号(+)的形式
print('第一种方式通过加号形式连接 :' + 'love'+'Python' + '\n')
第二种 通过逗号(,)的形式
print('第二种方式通过逗号形式连接 :' + 'love', 'Python' + '\n')
第三种 直接连接 中间有无空格均可
print('第三种方式通过直接连接形式连接 (一) :' + 'love''Python' + '\n')
print('第三种方式通过直接连接形式连接 (二) :' + 'love' 'Python' + '\n')
第四种 格式化
print('第四种方式通过格式化形式连接 :' + '%s %s' % ('love', 'Python') + '\n')
第五种 join方式连接
str_list = ['love', 'Python']
print('第五种方式通过join形式连接 :' + ''.join(str_list) + '\n')
运行结果
来源:http://blog.csdn.net/qq_878799579/article/details/74279842
标签:Python,字符串
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
PHP源码之 ext/mysql扩展部分
2023-07-21 18:24:20
ASP常见数学函数 Abs Atn Cos 等详解
2008-05-28 12:33:00
form表单的submit方法和submit事件
2008-10-15 11:22:00
一文带你搞懂JS中导入模块import和require的区别
2023-07-21 03:24:18
比较详细的Asp伪静态化方法及Asp静态化探讨
2011-04-14 10:41:00
SQL--JOIN之完全用法
2008-09-12 17:30:00
解读python基于netconf协议获取网元的数据
2023-06-29 20:26:23
![](https://img.aspxhome.com/file/2023/7/60297_0s.jpg)
Python OpenCV实现3种滤镜效果实例
2021-06-04 10:20:27
![](https://img.aspxhome.com/file/2023/3/64233_0s.jpg)
FrontPage2002简明教程四:网页超级链接
2008-09-17 11:23:00
![](https://img.aspxhome.com/file/UploadPic/200810/17/20081017113025456s.jpg)
Go语言的GOPATH与工作目录详解
2023-08-29 06:54:04
细品Dreamweaver MX 2004内建FW技术
2010-09-02 12:38:00
![](https://img.aspxhome.com/file/UploadPic/20072/200723113037414s.gif)
Asp WinHttp.WinHttpRequest.5.1 对象使用详解
2012-05-02 10:15:27
Dreamweaver MX打造弹出“向导”
2009-07-21 12:41:00
![](https://img.aspxhome.com/file/UploadPic/20071/200713110227823s.jpg)
使table也能overflow:hidden
2008-08-18 21:04:00
内部系统是否也需要用户体验设计?
2010-11-30 21:47:00
![](https://img.aspxhome.com/file/UploadPic/201011/30/t1ya4qxihpxxxxxxxx-500-222-89s.png)
MySQL鲜为人知的几个特殊技巧
2009-03-09 13:22:00
SQL Server中读取XML文件的简单做法
2008-12-23 15:29:00
go build失败报方法undefined的解决过程
2023-06-18 15:07:36
![](https://img.aspxhome.com/file/2023/8/87628_0s.png)
asp如何让页面背景五彩缤纷?
2010-05-13 16:38:00
网页颜色变黑白CSS代码 适合所有类型网站
2010-04-21 10:37:00