Reputation: 145
I'm trying to parse through a massive file for an iTunes library and I'm attempting to use plistlib library.
My code looks something like this:
import plistlib
with open('iTunes Music Library.xml') as fp:
pl = plistlib.load(fp)
print(pl["aKey"])
As I do so, I get the error:
TypeError: startswith first arg must be str or a tuple of str, not bytes
I'm not sure what this is, any explanations?
Upvotes: 1
Views: 1448
Reputation: 1938
You need to open the file as a binary, i.e.
with open('iTunes Music Library.plist', 'rb') as fp:
pl = plistlib.load(fp)
Upvotes: 0
Reputation: 281683
As stated in the docs, plistlib.load
takes a binary file object. You've given it a file opened in text mode.
Upvotes: 2