ตัดคำภาษาญี่ปุ่นด้วย Python
บทความนี้ผมจะพาผู้อ่านไปตัดคำภาษาญี่ปุ่นด้วย Python กันครับ
>>> import codecs
>>> codecs.decode("7061756c", "hex")
b'paul'
>>> str(codecs.decode("7061756c", "hex"))
"b'paul'"
>>> a= codecs.decode("7061756c", "hex")
>>> a.decode('utf-8')
'paul'
3C 4D 76 77 61 66
>>> import binascii
>>> binascii.unhexlify('3C 4D 76 77 61 66')
Traceback (most recent call last):
File "", line 1, in
TypeError: Odd-length string
>>> binascii.unhexlify(''.join('3C 4D 76 77 61 66'.split()))
'<Mvwaf'
>>> 0b101111
47
>>> print(int('01010101111',2))
687
>>> print(int('11111111',2))
255