设为首页 加入收藏

TOP

python 字符串操作一(二)
2017-12-23 06:07:15 】 浏览:266
Tags:python 字符串 操作
o}'.format(11) '13' >>> '{:x}'.format(11) 'b' >>> '{:#x}'.format(11) '0xb' >>> '{:#X}'.format(11) '0XB'
>>> '{:,}'.format(15700000000)
'15,700,000,000'

  

三、字符串模板

from string import Template

s = Template("Hi, $name! $name is learning $language")
print(s.substitute(name="Wilber", language="Python"))

d = {"name": "Will", "language": "C#"}
print(s.substitute(d))

# 用$$表示$符号
s = Template("This book ($bname) is 17$$")
print(s.substitute(bname="TCP/IP"))
Hi, Wilber! Wilber is learning Python
Hi, Will! Will is learning C#
This book (TCP/IP) is 17$

  

 

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇012函数 下一篇Matplotlib库的使用

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目