Article 6NBX8 Can I make these bytes human readable?

Can I make these bytes human readable?

by
Pedroski
from LinuxQuestions.org on (#6NBX8)
Someone was asking about reading old SD cards by sector. I think he wants to change the format of the data stored on the old SDs.

I don't know anything about this stuff!

This Python function reads sector 0 of an old usb stick I have:

Code:def read_sector(disk, sector_no=0):
"""Read a single sector of the specified disk.

Keyword arguments:
disk -- the physical ID of the disk to read.
sector_no -- the sector number to read (default: 0).
"""
# Static typed variable
read = None
# File operations with `with` syntax. To reduce file handeling efforts.
with open(disk, 'rb') as fp:
fp.seek(sector_no * 512)
read = fp.read(512)
return readIs it possible or even sensible to try to make these bytes humanreadable, to decode bites?
Is it possible to loop through all sectors looking for say, certain text?

Code:usb = '/dev/sda'
bites = read_sector(usb)I get:

Quote:
text = bites.decode('utf8')
Traceback (most recent call last):
File "/usr/lib/python3.10/idlelib/run.py", line 578, in runcode
exec(code, self.locals)
File "<pyshell#41>", line 1, in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 1: invalid start byte
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments