Sysops Notepad

[Python] base64 인코딩/디코팅 하는법 본문

업무/dev

[Python] base64 인코딩/디코팅 하는법

sysops 2019. 2. 15. 17:43


import base64

 

def stringToBase64(a):

    return base64.b64encode(a.encode('utf-8'))

 

def base64ToString(b):

    return base64.b64decode(b).decode('utf-8')

 

def fileToBase64(filepath):

    fp = open(filepath, "rb")

    data = fp.read()

    fp.close()

    return base64.b64encode(data).decode('utf-8')

'업무 > dev' 카테고리의 다른 글

[Python] 파이썬 *args,**kwargs 의미 (Asterisk(*))  (0) 2019.02.20
[Python] Jupyter 메모리 사용률 확인  (0) 2019.02.20
[bash] for문 사용법  (0) 2019.02.11
[Python] fluent-logger-python  (0) 2019.01.25
[bash] echo cmd option  (0) 2018.11.27
Comments