ã²ãããªãã«ã¿ã«ãã«ãã«ã¿ã«ããã²ãããªã«
çãç°¡åã«ã
ã³ã¼ãä¸ã® & #12436; ã£ã¦ããã®ã¯ãゔãã§ãï¼ä½æ
ãå¤æã§ããªãï¼
import re def make_function_hiragana(): re_katakana = re.compile(ur'[ã¡-ã´]') def hiragana(text): """ã²ãããªå¤æ""" return re_katakana.sub(lambda x: unichr(ord(x.group(0)) - 0x60), text) return hiragana hiragana = make_function_hiragana() def make_function_katakana(): re_hiragana = re.compile(ur'[ã-ゔ]') def katakana(text): """ã«ã¿ã«ãå¤æ""" return re_hiragana.sub(lambda x: unichr(ord(x.group(0)) + 0x60), text) return katakana katakana = make_function_katakana() text = u'ãã¤ã¿ã«ã¤ãããã¬' print hiragana(text) # ã«ããããã¾ã®ã¼ã text = u'ã«ãã«ãã«ãã®ã«ãã¨ã' print katakana(text) # ãã¯ãã¯ãã¯ããã¯ã㪠text = u'ä»æ¥ã®æ©ã飯ã¯ã«ã¬ã¼ã ' print hiragana(text) # ä»æ¥ã®æ©ã飯ã¯ããã¼ã print katakana(text) # ææ¥ãæ©ã´é£¯ãã«ã¬ã¼ã