[PYTHON] print Full-width characters + half-width characters

print_moji.py


#!/usr/bin/python
# -*- encoding: utf-8 -*-

print '-' * 60
print '#Half-width character'
print '| %%20s|%20s| %%20s|%20s|' % ('UTF-8','Unicode')
print '| %%20s|%20s| %%20s|%20s|' % ('-' * 20,'-' * 20)
print '| %%20s|%20s| %%20s|%20s|' % ('1'                    , u'1'                   )
print '| %%20s|%20s| %%20s|%20s|' % ('12'                   , u'12'                  )
print '| %%20s|%20s| %%20s|%20s|' % ('123'                  , u'123'                 )
print '| %%20s|%20s| %%20s|%20s|' % ('1234'                 , u'1234'                )
print '| %%20s|%20s| %%20s|%20s|' % ('12345'                , u'12345'               )
print '| %%20s|%20s| %%20s|%20s|' % ('123456'               , u'123456'              )
print '| %%20s|%20s| %%20s|%20s|' % ('1234567'              , u'1234567'             )
print '| %%20s|%20s| %%20s|%20s|' % ('12345678'             , u'12345678'            )
print '| %%20s|%20s| %%20s|%20s|' % ('123456789'            , u'123456789'           )
print '| %%20s|%20s| %%20s|%20s|' % ('1234567890'           , u'1234567890'          )
print '| %%20s|%20s| %%20s|%20s|' % ('12345678901'          , u'12345678901'         )
print '| %%20s|%20s| %%20s|%20s|' % ('123456789012345'      , u'123456789012345'     )
print '| %%20s|%20s| %%20s|%20s|' % ('12345678901234567890' , u'12345678901234567890')
print '-' * 60
print '#Double-byte character'
print '-'* 60
print '| %%20s|%20s| %%20s|%20s|' % ('12345678901234567890' , u'12345678901234567890')
print '-'* 60
print '| %%21s|%(moji)21s| %%20s|%(moji)20s|' % {'moji':'1'}
print '| %%22s|%(moji)22s| %%20s|%(moji)20s|' % {'moji':'12'}
print '| %%23s|%(moji)23s| %%20s|%(moji)20s|' % {'moji':'123'}
print '| %%24s|%(moji)24s| %%20s|%(moji)20s|' % {'moji':'1234'}
print '| %%25s|%(moji)25s| %%20s|%(moji)20s|' % {'moji':'12345'}
print '| %%26s|%(moji)26s| %%20s|%(moji)20s|' % {'moji':'123456'}
print '| %%27s|%(moji)27s| %%20s|%(moji)20s|' % {'moji':'1234567'}
print '| %%28s|%(moji)28s| %%20s|%(moji)20s|' % {'moji':'12345678'}
print '| %%29s|%(moji)29s| %%20s|%(moji)20s|' % {'moji':'123456789'}
print '| %%30s|%(moji)30s| %%20s|%(moji)20s|' % {'moji':'1234567890'}
print '-'* 60
print '#Double-byte character(Unicode string)'
print '-'* 60
print '| %%20s|%20s| %%20s|%20s|' % ('12345678901234567890' , u'12345678901234567890')
print '-'* 60
print '| %%19s|%(moji)19s| %%20s|%(moji)20s|' % {'moji':u'1'}
print '| %%18s|%(moji)18s| %%20s|%(moji)20s|' % {'moji':u'12'}
print '| %%17s|%(moji)17s| %%20s|%(moji)20s|' % {'moji':u'123'}
print '| %%16s|%(moji)16s| %%20s|%(moji)20s|' % {'moji':u'1234'}
print '| %%15s|%(moji)15s| %%20s|%(moji)20s|' % {'moji':u'12345'}
print '| %%14s|%(moji)14s| %%20s|%(moji)20s|' % {'moji':u'123456'}
print '| %%13s|%(moji)13s| %%20s|%(moji)20s|' % {'moji':u'1234567'}
print '| %%12s|%(moji)12s| %%20s|%(moji)20s|' % {'moji':u'12345678'}
print '| %%11s|%(moji)11s| %%20s|%(moji)20s|' % {'moji':u'123456789'}
print '| %%10s|%(moji)10s| %%20s|%(moji)20s|' % {'moji':u'1234567890'}
print '-'* 60
print '#Full-width characters + half-width characters'
print '-'* 60
print '| %%20s|%20s| %%20s|%20s|' % ('12345678901234567890' , u'12345678901234567890')
print '-'* 60
print '| %%21s|%(moji)21s| %%20s|%(moji)20s|' % {'moji':'1234567890123456789'}
print '| %%22s|%(moji)22s| %%20s|%(moji)20s|' % {'moji':'123456789012345678'}
print '| %%23s|%(moji)23s| %%20s|%(moji)20s|' % {'moji':'12345678901234567'}
print '| %%24s|%(moji)24s| %%20s|%(moji)20s|' % {'moji':'1234567890123456'}
print '| %%25s|%(moji)25s| %%20s|%(moji)20s|' % {'moji':'123456789012345'}
print '| %%26s|%(moji)26s| %%20s|%(moji)20s|' % {'moji':'12345678901234'}
print '| %%27s|%(moji)27s| %%20s|%(moji)20s|' % {'moji':'1234567890123'}
print '| %%28s|%(moji)28s| %%20s|%(moji)20s|' % {'moji':'123456789012'}
print '| %%29s|%(moji)29s| %%20s|%(moji)20s|' % {'moji':'12345678901'}
print '| %%30s|%(moji)30s| %%20s|%(moji)20s|' % {'moji':'1234567890'}
print '-'* 60
print '#Full-width characters + half-width characters(Unicode string)'
print '-'* 60
print '| %%20s|%20s| %%20s|%20s|' % ('12345678901234567890' , u'12345678901234567890')
print '-'* 60
print '| %%19s|%(moji)19s| %%20s|%(moji)20s|' % {'moji':u'1234567890123456789'}
print '| %%18s|%(moji)18s| %%20s|%(moji)20s|' % {'moji':u'123456789012345678'}
print '| %%17s|%(moji)17s| %%20s|%(moji)20s|' % {'moji':u'12345678901234567'}
print '| %%16s|%(moji)16s| %%20s|%(moji)20s|' % {'moji':u'1234567890123456'}
print '| %%15s|%(moji)15s| %%20s|%(moji)20s|' % {'moji':u'123456789012345'}
print '| %%14s|%(moji)14s| %%20s|%(moji)20s|' % {'moji':u'12345678901234'}
print '| %%13s|%(moji)13s| %%20s|%(moji)20s|' % {'moji':u'1234567890123'}
print '| %%12s|%(moji)12s| %%20s|%(moji)20s|' % {'moji':u'123456789012'}
print '| %%11s|%(moji)11s| %%20s|%(moji)20s|' % {'moji':u'12345678901'}
print '| %%10s|%(moji)10s| %%20s|%(moji)20s|' % {'moji':u'1234567890'}

result

------------------------------------------------------------
#Half-width character
| %20s|               UTF-8| %20s|             Unicode|
| %20s|--------------------| %20s|--------------------|
| %20s|                   1| %20s|                   1|
| %20s|                  12| %20s|                  12|
| %20s|                 123| %20s|                 123|
| %20s|                1234| %20s|                1234|
| %20s|               12345| %20s|               12345|
| %20s|              123456| %20s|              123456|
| %20s|             1234567| %20s|             1234567|
| %20s|            12345678| %20s|            12345678|
| %20s|           123456789| %20s|           123456789|
| %20s|          1234567890| %20s|          1234567890|
| %20s|         12345678901| %20s|         12345678901|
| %20s|     123456789012345| %20s|     123456789012345|
| %20s|12345678901234567890| %20s|12345678901234567890|
------------------------------------------------------------
#Double-byte character
------------------------------------------------------------
| %20s|12345678901234567890| %20s|12345678901234567890|
------------------------------------------------------------
| %21s|                  1| %20s|                 1|
| %22s|                12| %20s|              12|
| %23s|              123| %20s|           123|
| %24s|            1234| %20s|        1234|
| %25s|          12345| %20s|     12345|
| %26s|        123456| %20s|  123456|
| %27s|      1234567| %20s|1234567|
| %28s|    12345678| %20s|12345678|
| %29s|  123456789| %20s|123456789|
| %30s|1234567890| %20s|1234567890|
------------------------------------------------------------
#Double-byte character(Unicode string)
------------------------------------------------------------
| %20s|12345678901234567890| %20s|12345678901234567890|
------------------------------------------------------------
| %19s|                  1| %20s|                   1|
| %18s|                12| %20s|                  12|
| %17s|              123| %20s|                 123|
| %16s|            1234| %20s|                1234|
| %15s|          12345| %20s|               12345|
| %14s|        123456| %20s|              123456|
| %13s|      1234567| %20s|             1234567|
| %12s|    12345678| %20s|            12345678|
| %11s|  123456789| %20s|           123456789|
| %10s|1234567890| %20s|          1234567890|
------------------------------------------------------------
#Full-width characters + half-width characters
------------------------------------------------------------
| %20s|12345678901234567890| %20s|12345678901234567890|
------------------------------------------------------------
| %21s|1234567890123456789| %20s|1234567890123456789|
| %22s|123456789012345678| %20s|123456789012345678|
| %23s|12345678901234567| %20s|12345678901234567|
| %24s|1234567890123456| %20s|1234567890123456|
| %25s|123456789012345| %20s|123456789012345|
| %26s|12345678901234| %20s|12345678901234|
| %27s|1234567890123| %20s|1234567890123|
| %28s|123456789012| %20s|123456789012|
| %29s|12345678901| %20s|12345678901|
| %30s|1234567890| %20s|1234567890|
------------------------------------------------------------
#Full-width characters + half-width characters(Unicode string)
------------------------------------------------------------
| %20s|12345678901234567890| %20s|12345678901234567890|
------------------------------------------------------------
| %19s|1234567890123456789| %20s| 1234567890123456789|
| %18s|123456789012345678| %20s|  123456789012345678|
| %17s|12345678901234567| %20s|   12345678901234567|
| %16s|1234567890123456| %20s|    1234567890123456|
| %15s|123456789012345| %20s|     123456789012345|
| %14s|12345678901234| %20s|      12345678901234|
| %13s|1234567890123| %20s|       1234567890123|
| %12s|123456789012| %20s|        123456789012|
| %11s|12345678901| %20s|         12345678901|
| %10s|1234567890| %20s|          1234567890|

Recommended Posts

print Full-width characters + half-width characters
Power Automate Desktop Half-width and full-width conversion of katakana and alphanumeric characters