代码示例
#!/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。