美文网首页
python编程常用函数

python编程常用函数

作者: 笑起来真好看ccn | 来源:发表于2023-11-09 16:28 被阅读0次

1.round(m,1):#四舍五入

2.小数

n=int(input())

m=float("%.2f"%n) #转换为2位小数

3.大小写

.lower() --- 全部小写

.upper() --- 全部大写

.title() --- 各个字符的首字母大写

.capitalize() --- 首字母大写

4.去掉首尾空格

n=input()

print(n.strip())

5.截取前10个字符

n=input()

m=n[:10]

print(m)

相关文章

网友评论

      本文标题:python编程常用函数

      本文链接:https://www.haomeiwen.com/subject/pjicwdtx.html