Coding/Python
문자열->hex, hex->문자열 < 문자열.[encode|decode]("방식") >
0w0
2016. 11. 12. 07:36
728x90
반응형
입력한 문자열을 hex로
encode 함수를 사용!!
>>> input_str=raw_input("String : ")
String : ABCD
>>> print input_str
ABCD
>>> input_str.encode("hex")
'41424344'
hex를 문자열로
decode 함수를 사용!!
>>> hex_value=input_str.encode("hex")
>>> hex_value.decode("hex")
'ABCD'
문자열을 base64로
>>> a=input_str.encode("base64")
>>> print a
QUJDRA==
base64를 문자열로
>>> a.decode("base64")
'ABCD'
< 문자열.[encode|decode]("방식") >
728x90
반응형