I'm trying to write a program to get the artist and album from mp3 files. A simple test run on the Alice in Chanins song Rooster yielded this result -> b'Rooster\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
I set read to read(20) and if you count Rooster plus all the \x00s you'll see that it 20, I'm confused because that chould be 20 bytes and \x00 is 4 bytes. I need to be able to tell the program to stop building the artist string after it hits \x00, how can represent that? Thanks.
lewashby
56
Junior Poster
Recommended Answers
Jump to Post\x00 is byte, not 4, you can strip those with
.rstrip('\x00')
>>> b'Rooster\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 'Rooster\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' >>> _.rstrip('\x00') 'Rooster' >>>
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.