python實現(xiàn)基本進制轉換的方法
來源:懂視網(wǎng)
責編:小采
時間:2020-11-27 14:34:24
python實現(xiàn)基本進制轉換的方法
python實現(xiàn)基本進制轉換的方法:本文實例講述了python基本進制轉換的方法。分享給大家供大家參考。具體如下: # Parsing string with base into a number is easy num = int(str, radix) # We have to write our own function for outputting
導讀python實現(xiàn)基本進制轉換的方法:本文實例講述了python基本進制轉換的方法。分享給大家供大家參考。具體如下: # Parsing string with base into a number is easy num = int(str, radix) # We have to write our own function for outputting
本文實例講述了python基本進制轉換的方法。分享給大家供大家參考。具體如下:
# Parsing string with base into a number is easy
num = int(str, radix)
# We have to write our own function for outputting to string with arbitrary base
def itoa(num, radix):
result = ""
while num > 0:
result = "0123456789abcdefghijklmnopqrstuvwxyz"[num % radix] + result
num /= radix
return result
希望本文所述對大家的Python程序設計有所幫助。
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
python實現(xiàn)基本進制轉換的方法
python實現(xiàn)基本進制轉換的方法:本文實例講述了python基本進制轉換的方法。分享給大家供大家參考。具體如下: # Parsing string with base into a number is easy num = int(str, radix) # We have to write our own function for outputting