先来看看一些基础的函数
a
= "AbCdeFG"
print( a
.lower
() + " " + a
.upper
())
print( "a,b,c".split
(",") )
print("an apple a day".count
("a") )
print("python".replace
("n" , "123.com"))
print("pyrhon".center
( 20 , "=" ))
print( "=python=".strip
(" =np") )
print( ",".join
("12345") )
运行结果如下
接着我们再看format函数中的字符使用
print("{0}:计算机{1}的cup占用率为{2:.2f}%".format("2020-10-12" , "C" , 10.0 ) )
print("{:>20.2f}".format(1.21))
print("{:,.2f}".format(12345))
转载请注明原文地址: https://lol.8miu.com/read-11439.html