Skip to content

Instantly share code, notes, and snippets.

@U29
Last active August 18, 2021 07:57
Show Gist options
  • Save U29/463235c1212f51018880b71817629fab to your computer and use it in GitHub Desktop.
Save U29/463235c1212f51018880b71817629fab to your computer and use it in GitHub Desktop.
半角数字を全角数字に変換する関数 (Python2.x and Python3.x)
# -*- coding: utf-8 -*-
def convert_num_half_to_full(h_num):
F_NUM_LIST = ["0","1", "2", "3","4", "5", "6", "7", "8", "9"]
f_num_str = ""
h_num_str = str(h_num)
for string in h_num_str:
f_num_str += F_NUM_LIST[int(string)]
return f_num_str
# Sample #
print(convert_num_half_to_full(3))
print(convert_num_half_to_full(19))
print(convert_num_half_to_full(241020))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment