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

查看所有标签

Algorithms + Data Structures = Programs

Algorithms + Data Structures = Programs

Niklaus Wirth / Prentice Hall / 1975-11-11 / GBP 84.95

It might seem completely dated with all its examples written in the now outmoded Pascal programming language (well, unless you are one of those Delphi zealot trying to resist to the Java/.NET dominanc......一起来看看 《Algorithms + Data Structures = Programs》 这本书的介绍吧!

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

各进制数互转换器

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具