s = " test {0} zhang {last_name} blog {1} "
s1 = s.format("2019", "csdn", last_name="fly")
print(s1.capitalize())
print(s1.title())
print(s1.strip())
print(s1.count("t"))
print(s1.find("t", 1, len(s1)))
print(s1.rfind("t"))
print(s1.split())
print(s1.rjust(51,"0"))
print(s1.zfill(50))
print(s1)
输出:
test 2019 zhang fly blog csdn
Test 2019 Zhang Fly Blog Csdn
test 2019 zhang fly blog csdn
2
1
4
['test', '2019', 'zhang', 'fly', 'blog', 'csdn']
00000000000000000000 test 2019 zhang fly blog csdn
0000000000000000000 test 2019 zhang fly blog csdn
test 2019 zhang fly blog csdn