python3必须带decode(encoding=“utf-8”)或decode(“utf-8”)
读文件写文件:
a="admin:"
with open("123.txt","w+") as fp: #写文件
for i in range(100):
b=str(i) #转字符串
fp.write(a+b)#以admin: ??的形式输出
fp.write('\n')#换行继续写
with open("123.txt") as fb:#读文件
content=fb.read()
print(content)
md5转码:
import hashlib
filename = "1.php"
for i in range(1001):
flagname = filename + str(i)
flagnameMd5 = hashlib.md5()
flagnameMd5.update(flagname.encode(encoding="utf-8"))
print (flagnameMd5.hexdigest())
base64:
import base64
a="123"
b=base64.b64encode(str(a).encode(encoding="utf-8"))#加密
c=base64.b64decode(str(b).decode("utf-8"))#解密
print(b)