[python] 字符串

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013608336/article/details/82593711

常用函数

len
lstrip
strip
rstrip

字符串格式化

>>> 'Hi, %s, you have $%d.' % ('Michael', 1000000)
'Hi, Michael, you have $1000000.'
#格式化整数和浮点数还可以指定是否补0和整数与小数的位数
print('%2d-%02d' % (3, 1))  
print('%.2f' % 3.1415926)   3.14

占位符 替换内容
%d 整数
%f 浮点数
%s 字符串
%x 十六进制整数

其他链接
google python 风格指南(https://zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/python_style_rules/

猜你喜欢

转载自blog.csdn.net/u013608336/article/details/82593711