方法 | 描述 |
---|---|
classmethod bytearray.fromhex(string) | 將具有十六進位數字的字串 string 轉換為字節陣列 |
舉例示範如下
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 | a = "f0 f1 f2 f3 f4" print (a) print (bytearray.fromhex(a)) print () b = "01 2345" print (b) print (bytearray.fromhex(b)) print () c = "12 13 14 15 16" print (c) print (bytearray.fromhex(c)) print () d = "1213141516" print (d) print (bytearray.fromhex(c)) print () # 《程式語言教學誌》的範例程式 # 檔名:bytearrayfromhex.py # 功能:示範 Python 程式 # 作者:張凱慶 # 時間:西元 2010 年 12 月 |
執行結果如下

中英文術語對照 | |
---|---|
字節陣列 | bytearray |
型態 | type |
方法 | method |
沒有留言:
張貼留言