Guest User

Untitled

a guest
Nov 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. max_digit = 10 # 最大桁数(intなら10桁)
  4. dic = ['0','1','2','3','4','5','6','7','8','9']
  5.  
  6. def itoa(num):
  7. result = ''
  8. previous = 0
  9. for i in range(max_digit,-1,-1):
  10. temp = num / (10**i)
  11. if temp > 0:
  12. result += dic[temp - previous *10]
  13. previous = temp
  14. return result
  15.  
  16. if __name__ == '__main__':
  17. print itoa(102340)
Add Comment
Please, Sign In to add comment