文中Python源码中%10的作用是什么,,x = "There a
文中Python源码中%10的作用是什么,,x = "There a
x = "There are %d types of people." % 10
这个叫格式化字符串。
>>> uid = "sa">>> pwd = "secret">>> print pwd + " is not a good password for " + uidsecret is not a good password for sa>>> print "%s is not a good password for %s" % (pwd, uid) secret is not a good password for sa>>> userCount = 6>>> print "Users connected: %d" % (userCount, ) Users connected: 6>>> print "Users connected: " + userCount Traceback (innermost last): File "<interactive input>", line 1, in ?TypeError: cannot concatenate 'str' and 'int' objects
更多可以看 Dive Into Python - 格式化字符串
其他语言的printf
>>>x = "a %d c" % 10 >>>print xa 10 c
编橙之家文章,
相关内容
- pyInstaller 打包py文件在warn.txt中报missing module,,是在li
- BeautifulSoup append<>尖括号不被转换成实体的方
- 我把virtualenv目录改了新名字,发现pip安装包无法识别了
- web.py在note页面中应该如何接收值的传入,web.pynote,在
- Python web make_server方式与直接运行区别是什么,pythonma
- 对于python循环嵌套应用不太理解,求手高指教,python手高
- Python模版功能实现的原理是什么?,python模版,我一直使
- Python如何反向解析固定格式log,python解析格式log,怎样按
- Python有提供类似拼图模块吗,python类似拼图模块,我想在
- 腾讯云VPS主机python flask host 绑定出问题,vpsflask,app.ru
评论关闭