久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Python從二進制字符串轉換為十六進制

Python conversion from binary string to hexadecimal(Python從二進制字符串轉換為十六進制)
本文介紹了Python從二進制字符串轉換為十六進制的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

如何在 Python 中將二進制字符串轉換為對應的十六進制值?

我有 0000 0100 1000 1101 我想獲得 048D 我正在使用 Python 2.6.

解決方案

int 給定 base 2 然后 hex:

>>>整數('010110',2)22>>>十六進制(整數('010110',2))'0x16'>>>>>>十六進制(整數('0000010010001101',2))'0x48d'

int的文檔:

<塊引用>

int(x[, base]) ->整數如果可能,將字符串或數字轉換為整數.一個漂浮的

點參數將被截斷為零(這不包括字符串浮點數的表示!)轉換字符串時,利用可選基地.轉換 a 時提供堿基是錯誤的非字符串.如果基數為零,則根據字符串內容.如果參數超出整數范圍將改為返回長對象.

hex的文檔:

<塊引用>

十六進制(數字)->細繩返回整數或長整數的十六進制表示

整數.

How can I perform a conversion of a binary string to the corresponding hex value in Python?

I have 0000 0100 1000 1101 and I want to get 048D I'm using Python 2.6.

解決方案

int given base 2 and then hex:

>>> int('010110', 2)
22
>>> hex(int('010110', 2))
'0x16'
>>> 

>>> hex(int('0000010010001101', 2))
'0x48d'

The doc of int:

int(x[, base]) -> integer

Convert a string or number to an integer, if possible.  A floating

point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If base is zero, the proper base is guessed based on the string content. If the argument is outside the integer range a long object will be returned instead.

The doc of hex:

hex(number) -> string

Return the hexadecimal representation of an integer or long

integer.

這篇關于Python從二進制字符串轉換為十六進制的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 亚洲国产精品久久 | 免费久 | 色橹橹欧美在线观看视频高清 | 武道仙尊动漫在线观看 | 国产精品一区在线观看 | 精品国产精品三级精品av网址 | 亚洲aⅴ精品 | 妞干网福利视频 | 国产精品精品久久久 | 亚洲一级黄色 | 草草草草视频 | 怡红院怡春院一级毛片 | 精品久久久999 | 久久国产精品99久久久久 | 亚洲精品二区 | 国产一区二区在线视频 | 久久se精品一区精品二区 | 青青草社区 | 国产一级片91 | 国产精品二区三区在线观看 | 亚洲国产一区视频 | 国产成人精品一区二 | 在线观看成人 | 九九热免费观看 | 婷婷久久五月天 | 久草新视频 | 欧美一级二级视频 | 日韩av一区在线观看 | 日韩不卡视频在线 | 亚洲精品日韩综合观看成人91 | 婷婷福利| 91视频一区 | 久久综合九色综合欧美狠狠 | 特级一级黄色片 | 国产精品久久久久久吹潮 | 中文字幕一区在线观看视频 | 欧美视频成人 | 国产成人精品一区二 | 亚洲成人精品一区二区 | 亚洲一区二区免费 | 国产精品久久久久av |