The issue is that Safari's plist file is actually a binary plist file format, which the built-in plistlib
can't read. However, biplist can read these files (requires installation):
>>> import biplist
>>> x = biplist.readPlist("com.apple.Safari.plist")
>>> x['LastOSVersionSafariWasLaunchedOn']
'10.9.1'
Alternatively, you can use plutil
to first convert the binary plist format to xml format, and then read it using plistlib
:
$ plutil -convert xml1 com.apple.Safari.plist
$ python
>>> import plistlib
>>> x = plistlib.readPlist("com.apple.Safari.plist")
>>> x['LastOSVersionSafariWasLaunchedOn']
'10.9.1'