fork download
  1. import unicodedata
  2.  
  3. words = '''あいう'12"3456'''
  4.  
  5. print("半角の文字は以下です")
  6. for elem in words:
  7. res = unicodedata.east_asian_width(elem)
  8. if res == 'Na':
  9. print(elem)
  10.  
  11. print("全文字のeast_asian_width()結果")
  12. for elem in words:
  13. res = unicodedata.east_asian_width(elem)
  14. print(elem, res)
  15.  
  16.  
Success #stdin #stdout 0.04s 9400KB
stdin
Standard input is empty
stdout
半角の文字は以下です
'
1
"
4
全文字のeast_asian_width()結果
あ W
い W
う W
' Na
1 Na
2 F
" Na
3 F
4 Na
5 F
6 F