python字符串嵌套与变量之间的问题,python嵌套,有没有类似于ruby那样
python字符串嵌套与变量之间的问题,python嵌套,有没有类似于ruby那样
有没有类似于ruby那样的方式
number = 5
“This number is #{number}.“ #=>“This number is 5.“
"This number is %s. " % number
print "This number is {number}.".format(number=5)
貌似就三楼跟你要的比较类似。
@testcpast 写的是占位符方式已经挺优雅的了,下面还有2种,这样会不会更难看?
用+号不难看?
print "This number is "+ str(number) + "."
用逗号不难看?
print "This number is", number, "."
python没有你想要的这种字符串连接变量的方式
编橙之家文章,
相关内容
- Python如何捕获微信摄推送服务端事件思路,python服务端
- python运行环境哪种轻巧又实用,python运行环境,在本机开
- 求问如下python解析库工作原理是什么,python工作原理
- Celery采用线程gevent并发模式启动具体方式是什么样的,
- Python做数据统计框架哪个好,python数据统计框架,如题。
- Python怎样实现在同一张图上画两次,python张图上画,如题
- Python支持调用其它语言函数吗?例如C++代码或Java包函数
- python正则表达式中函数findall用法?,pythonfindall,1.我的
- 问BeautifulSoup获得标签描述信息python源码怎么写,,
- Python协程同步问题求助asyncio模块,pythonasyncio,在Window
评论关闭