python读取文件并进行Base64编码解码

import os
import sys
import base64

def b64file():
    res = ""
    t1 = ""
    with open("deploy.cnf") as f:
        lines =  f.readlines()
        for line in lines:
            # print(line)
            res =  res + line
            # t1 =  t1 + str(base64.b64encode(line.encode()), "utf-8")
    print(res)
    t1 =  str(base64.b64encode(res.encode()), "utf-8")
    print(t1)
    appenv2 = str(base64.b64decode(t1), "utf-8")
    print("----",appenv2)
    print("----")
    return res

# b64file()

def db64file():
    job1appenv1 = 'aGVsbG93b3JsZApuaWhhb3lhCmNoaW5hCjEyMzQ1CjIzMzQ='
    appenv2 = str(base64.b64decode(job1appenv1), "utf-8")
 
    print(appenv2)
    with open("a.txt","w") as f:
        f.write(appenv2)
    # print(b)

db64file()



你可能感兴趣的:(python,java,前端)