将十六进制字符串表示形式转换为在python中浮动 [英] Converting hex string representation to float in python

查看:82
本文介绍了将十六进制字符串表示形式转换为在python中浮动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有IEEE 745十六进制格式的数据:0x1.5c28f5c28f5c3p-1

I have data in IEEE 745 hexadecimal format: 0x1.5c28f5c28f5c3p-1

我如何将其转换为python中的float?这是标准模块吗?

How would I convert this to a float in python? is this a standard module?

推荐答案

>>> float.fromhex('0x1.5c28f5c28f5c3p-1')
0.68

它在标准库 float.fromhex 中.

It's in the standard library, float.fromhex.

这篇关于将十六进制字符串表示形式转换为在python中浮动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆