2013-04-27 51 views
1

http://docs.python.org/release/2.4.4/lib/typesseq-strings.html爲什麼python輸出負十六進制?

表說無符號十六進制,我的輸出簽署...

for a in words: # list of word 
    print '%x'%hash(a) 

http://codepad.org/Cvd0Bg2T

+1

您還應該顯示您的輸出 – jamylak 2013-04-27 22:51:58

+0

並顯示您的代碼。 – marcadian 2013-04-27 22:53:27

+1

所以你想讓我們猜測你的代碼的哪個部分是錯誤的,而沒有真正看到它? – 2013-04-27 22:54:57

回答

4

該文檔是爲Python 2.4。您可能正在使用更新的版本。看看該表的newer版本 - %x現在已經簽署。

2

該變化出現(或似乎)在2.6;在http://docs.python.org/release/2.5.4/lib/typesseq-strings.html中,U查找: ... x無符號十六進制(小寫)。 in http://docs.python.org/release/2.6/library/stdtypes.html#string-formatting: ... 'x'帶符號的十六進制(小寫)。

不是一個關於2.6的變化字「什麼新的」

新政策從「printf的」政策部分。在調試C代碼時,我曾經有一個ipython解釋器打開,位於我的gdb終端旁邊,用於計算地址。這不再工作,我發現不容易週轉。