Python plist parser IOError: [Errno 63] File name too long:
my Python plist parser does not like my long string that is in plist format.
plist_data = plistlib.readPlist(plistString)
plistString is actually the contents of the file I opened. Oddly enough, putting the input file into the readPlist function works, but I had to do some further fo开发者_StackOverflowrmatting of that file within python.
I run that above code and get an IOError: [Errno 63]
on the console. Not sure how to avoid this? I am guessing the function is looking for "raw" input, instead of a String. How do I trick it?
If you want to read a string as a file, use StringIO.
fakeFile= StringIO.StringOI( plistString )
plist_data = plistlib.readPlist(fakeFile)
It's better not to open and read the pList file. plistlib.readPlist
does the opening and reading for you.
plistlib.readPlist
takes file or file name, not contents. No surprise you get this error:
#define ENAMETOOLONG 63 /* File name too long */
Try plistlib.readPlistFromBytes(data)
or use StringIO to present your string as a file
精彩评论