How to convert an integer to a string in any base?

前端 未结 27 3088
清歌不尽
清歌不尽 2020-11-22 02:25

Python allows easy creation of an integer from a string of a given base via

int(str, base). 

I want to perform the inverse: creati

27条回答
  •  清酒与你
    2020-11-22 02:44

    num = input("number")
    power = 0
    num = int(num)
    while num > 10:
        num = num / 10
        power += 1
    
    print(str(round(num, 2)) + "^" + str(power))
    

提交回复
热议问题