AttributeError:模块“ base64”没有属性“ b64decode”

时间:2019-02-20 20:43:42

标签: python base64

代码示例

#!/usr/bin/python
#-*- coding:utf-8 -*-
import os
import base64

def ayristir(path):
    dirList=os.listdir(path)
    dirList.sort()

    fnames = []
    dnames = []

    for fname in dirList:
        if os.path.isdir(path + fname):
            dnames.append(fname)
        if os.path.isfile(path + fname):
            fnames.append(fname)

    return dnames,fnames

(klasorler,dosyalar) = ayristir("//home//siyah//Desktop//Veriler//")
for item in klasorler:
    print("Dizin => " + item)

for item in dosyalar:
     os.chdir("//home//siyah//Desktop//Veriler//")
     data = open(item, "r").read()
     decoded = base64.b64decode(data)
     gm = str((decoded))

     print(gm)
     kayit = open("data.txt" , "wb")
     kayit.write(gm)
     kayit.close() 

我需要:以字符串格式保存编码...

  

Python:TypeError:需要一个类似字节的对象,而不是'str'

我要做的是查找并解析使用base64加密的文件,然后将base64s注册到data.txt中,并将其解析为data.txt。

0 个答案:

没有答案