1 关于字符串大小写
- 全部大写 upper()
s = 'the quick brown fox'
print(s.upper())
-----
THE QUICK BROWN FOX
- 全部小写 lower()
s = 'the quick brown fox'
print(s.upper())
----
the quick brown fox
- 每个单词的第一个字母大写
import string
s = 'the quick brown fox'
print(string.capwords(s))
------
The Quick Brown Fox
2 关于format格式化函数
a1 = 'hello'
a2 = 'world'
print('{} {}'.format(a1,a2))
-----
hello world
2.1 %的用法
是的,最简单的是用%来传递;%d表示整数,%s表示字符串,%f表示浮点型。
a1 = 'hello'
a2 = 'world'
print('%s %s'%(a1,a2))
----
hello world
看各位的习惯啦~
16万+

被折叠的 条评论
为什么被折叠?



