2
我正在使用ImageHash模塊獲取圖像的哈希值。我有這樣的代碼:Python中zfill方法的說明
hashSize = 8
imghash3 = []
image = "pic1.jpg"
imghash1 = imagehash.phash(Image.open(image))
print(imghash1)
>>>d1d1f1f3f3737373
imghash2 = str(imagehash.phash(Image.open(image), hashSize))
print(imghash2)
>>>11b97c7eb158ac
imghash3.append(bin(int(imghash2, 16))[2:].zfill(64))
print(imghash3)
>>>['0000000000010001101110010111110001111110101100010101100010101100']
所以imagehash1
是該模塊的基本用法。
現在我不明白的是hashSize
對imagehash2
中原始字符串所做的轉換以及第3個函數如何將imagehash2
轉換爲64位字符串。
*「這一行」 *是什麼線?請不要寫這樣一個毫無意義的標題,然後通過發佈多行來使其錯誤。 –
我很抱歉,但我真的不知道如何描述它。你能給我一個更明確的標題嗎? – Hyperion