Discuss / Python / chr可以print,bytes不能print

chr可以print,bytes不能print

Topic source

老夫007

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

'ABC'.encode('utf-8')    #不能print

b'ABC'.decode('utf-8')  #可以print

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

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

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

统一用utf-8编码

老夫007

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

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

老夫007

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

不对不对,都可以print

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

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


  • 1

Reply