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

Python從二進制字符串轉(zhuǎn)換為十六進制

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

問題描述

如何在 Python 中將二進制字符串轉(zhuǎn)換為對應(yīng)的十六進制值?

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

解決方案

int 給定 base 2 然后 hex:

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

int的文檔:

<塊引用>

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

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

hex的文檔:

<塊引用>

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

整數(shù).

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.

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

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

相關(guān)文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區(qū)域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應(yīng)用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據(jù)文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 男女视频免费 | 成人a视频在线观看 | 欧美 日韩 在线播放 | 高清国产一区二区 | 丁香六月激情 | 国产乱一区二区三区视频 | 爱爱无遮挡 | 日韩综合一区 | 99久久婷婷国产综合精品 | 国产精品久久久久久妇女6080 | 国产一区二区日韩 | 91精品国产91久久久久久 | 亚洲精品日韩欧美 | 91天堂| 久久久123| 亚洲精品一区国语对白 | 四虎成人在线播放 | 天天操天天舔 | 色站综合 | av黄色片在线观看 | 久久精品欧美一区二区三区不卡 | 欧美色视频免费 | 亚洲精品久久久久久宅男 | 日韩中文字幕一区 | 国产小u女发育末成年 | 中文字幕综合 | 在线观看中文字幕dvd播放 | 国产一区二区在线观看视频 | 欧美高清视频 | 91精品国产91久久久久久丝袜 | 日韩欧美视频在线 | 久久婷婷国产 | 亚洲第一中文字幕 | 亚洲国产欧美在线人成 | 成人精品国产一区二区4080 | 欧美99| 亚洲码欧美码一区二区三区 | 日本小电影网站 | 欧美日韩国产在线 | 亚洲国产精品第一区二区 | 在线播放一区二区三区 |