Read Binary File - Python Programming Challenges

preview_player
Показать описание
This tutorial will teach you how to read a binary file or a file that contains binary numbers or values.
This tutorial is part of the Python Challenges series and is meant to increase the programming skills of beginner Python users.
Рекомендации по теме
Комментарии
Автор

This video is not at all about reading a binary file. It's about reading a text file which contains only the characters '0'' and '1' and treating it as if it were binary, which it clearly is not.

stephenaustin
Автор

Can you make a tutorial on stdin, stdout, stderr

sunithabinu
Автор

why i am not getting the output, First i converted the text file to binary and after getting the binary output i saved it in text file again
and trying to get the string back .
Here is my code:

f = open("mydjangonotes.txt", "r+")

test_str = f.read()

#print("The original string is : " + str(test_str))

res = ''.join(format(ord(i), 'b') for i in test_str)

bin_d = str(res)

#print("The string after binary conversion : ", bin_d )

f.truncate(0)

f.seek(0)

f.write(bin_d)

f.close()



f = open("mydjangonotes.txt", "r")

text = f.read()

print("value-", text)

f.close()



with open('mydjangonotes.txt', 'r') as f:

data = f.read(8)



while data!= '':

plaintext = chr(int(data, 2))

print(plaintext, end="")

data=f.read(8)

theInspireVista
join shbcf.ru