浮點數型態 (type) 的 fromhex() 方法 (method) ,將表示十六進位數字字串的 s 轉換成浮點數
方法 | 描述 |
classmethod float.fromhex(s) | 將表示十六進位數字字串的 s 轉換成浮點數 |
舉例示範如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | d1 = 0.5
print (d1)
d2 = d1. hex ()
print (d2)
d3 = float .fromhex(d2)
print (d3)
print ()
d1 = 0.008
print (d1)
d2 = d1. hex ()
print (d2)
d3 = float .fromhex(d2)
print (d3)
print ()
d1 = 22.005
print (d1)
d2 = d1. hex ()
print (d2)
d3 = float .fromhex(d2)
print (d3)
print ()
|
執行結果如下
內建型態
- 數字型態 int float complex 按一下展開目錄
- 迭代器型態
- 序列型態 按一下展開目錄
- 字串 str 按一下展開目錄
- str.capitalize()
- str.center(width[, fillchar])
- str.count(sub[, start[, end]])
- str.encode(encoding="utf-8", errors="strict")
- str.endswith(suffix[, start[, end]])
- str.expandtabs([tabsize])
- str.find(sub[, start[, end]])
- str.format(*args, **kwargs)
- str.index(sub[, start[, end]])
- str.isalnum()
- str.isalpha()
- str.isdecimal()
- str.isdigit()
- str.isidentifier()
- str.islower()
- str.isnumeric()
- str.isprintable()
- str.isspace()
- str.istitle()
- str.isupper()
- str.join(iterable)
- str.ljust(width[, fillchar])
- str.lower()
- str.lstrip([chars])
- static str.maketrans(x[, y[, z]])
- str.partition(sep)
- str.replace(old, new[, count])
- str.rfind(sub[, start[, end]])
- str.rindex(sub[, start[, end]])
- str.rjust(width[, fillchar])
- str.rpartition(sep)
- str.rsplit([sep[, maxsplit]])
- str.rstrip([chars])
- str.split([sep[, maxsplit]])
- str.splitlines([keepends])
- str.startswith(prefix[, start[, end]])
- str.strip([chars])
- str.swapcase()
- str.title()
- str.translate(map)
- str.upper()
- str.zfill(width)
- range
- 串列 list 按一下展開目錄
- 序對 tuple
- 字節 bytes 按一下展開目錄
- 字節陣列 bytearrary 按一下展開目錄
- 集合型態 set frozenset 按一下展開目錄
- 配對型態 dict 按一下展開目錄
沒有留言:
張貼留言