我正在尝试解码位于.txt文件中的二进制文件,但我卡住了.我没有看到任何可能出现的可能性.
def code(): testestest
ascii = {'01000001':'A', ...}
binary = {'A':'01000001', ...}
print (ascii, binary)
def encode():
pass
def decode(code,n):
f = open(code, mode='rb') # Open a file with filename <code>
while True:
chunk = f.read(n) # Read n characters at time from an open file
if chunk == '': # This is one way to check for the End Of File in Python
break
if chunk != '\n':
# Process it????
pass
Run Code Online (Sandbox Code Playgroud)
如何获取.txt文件中的二进制文件并将其输出为ASCII?