Discuss / Python / 字符串和编码总结

字符串和编码总结

Topic source

老夫007

#1 Created at ... [Delete] [Delete and Lock User]

print('ABC'.encode('utf-8') )

print(b'ABC'.decode('utf-8'))

占位符替换内容

%d整数
%f浮点数
%s字符串
%x十六进制整数
%%     %

'%.2f' % 3.1415    #2位小数

'%03d' % 1           #3位宽度,自动补0

统一用utf-8编码 无BOM

# -*- coding: utf-8 -*-


  • 1

Reply