Discuss / Python / 我的作业和关于大家讨论的hex()得出的类型

我的作业和关于大家讨论的hex()得出的类型

Topic source

macandle

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

首先是作业:

--coding:utf-8 --

n1 = 255 n2 = 1000

print('n1的十六进制是:',hex(n1)) print('n2的十六进制是:',hex(n2))

输出结果:

n1的十六进制是: 0xff n2的十六进制是: 0x3e8

====================================

然后关于大家讨论的hex() 的出来的是否是字符串的问题,请看如下:

n1 = 100 hex(n1) '0x64' type(hex(n1))

<class 'str'>

str 是字符串。


  • 1

Reply