Language/Python
[Python] int 진법 변환 시 에러
EunGyeongKim
2022. 8. 5. 15:07
n진법 -> 10진법으로 변환시 에러
num, base = map(int, input().strip().split(' '))
int(num, base)
이런식으로 n진법을 10진법으로 변환해줄때
----> print(int(num, base))
TypeError: int() can't convert non-string with explicit base
type에러가 나타난다.
num이 string이 아니라서 생기는 문제!
걍 num을 str형태로 바꿔주면 된다!
에러 수정 코드
num, base = map(int, input().strip().split(' '))
int(str(num), base)
에러 해결 끝! :D