Python hex() 函数

Python 3 教程 · 2019-02-05 11:27:42

描述

hex() 函数用于将10进制整数转换成16进制,以字符串形式表示。

语法

hex 语法:

hex(x)

参数说明:

  • x -- 10进制整数

返回值

返回16进制数,以字符串形式表示。

实例

以下实例展示了 hex 的使用方法:

>>>hex(255) '0xff' >>> hex(-42) '-0x2a' >>> hex(1L) '0x1L' >>> hex(12) '0xc' >>> type(hex(12)) <class 'str'> # 字符串

点击查看所有 Python 3 教程 文章: https://codercto.com/courses/l/10.html

查看所有标签

Code

Code

Charles Petzold / Microsoft Press / 2000-10-21 / USD 29.99

Paperback Edition What do flashlights, the British invasion, black cats, and seesaws have to do with computers? In CODE, they show us the ingenious ways we manipulate language and invent new means of ......一起来看看 《Code》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

html转js在线工具
html转js在线工具

html转js在线工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试