Python 扩展 OSX 路径,其中包含空格

发布于 12-06 18:21 字数 1480 浏览 1 评论 0原文

我正在尝试修改 plist 文件: /Volumes/MacintoshHD/Users/christian/Library/Application Support/iPhone Simulator/4.3.2/Library/Preferences/com.apple.Accessibility.plist

这是我的 noob python 脚本:

import plistlib
import os.path

#set path 
prefs_path = os.path.expanduser("~/Library/Application\ Support/iPhone\ Simulator/5.0/Library/Preferences/com.apple.Accessibility.plist")

#parse
prefs = plistlib.readPlist(prefs_path)

我得到 IOError: 2, 'No such file or directory'

如果我从我得到的路径中删除反斜杠ExpatError:'格式不正确(无效令牌):第 1 行,第 8 列'

更新

Ignacio Vazquez-Abram 的回答表明该文件已损坏。它仍然可以使用 Xcode 进行编辑并使用 Quicklook 进行查看。模拟器也运行良好。

当我在textmate中打开它时,我看到的只是:

bplist00ÿ           
D   _ApplicationAccessibilityEnabled_VOTQuickNavEnabled_AccessibilityEnabled]ScreenCurtain_"VoiceOverTouchRotorItemsPreference_AXInspector.enabled_AXInspector.frame_AXInspectorEnabled         Ø"%(+.147:=@“   YRotorItemWEnabledYCharacter    “   TWord   “   TLine   “   VHeader “   TLink   “   [FormElement    “#  ZTableStart “&YListStart“)YLandmarks“,[VisitedLink“/^NonVisitedLink“2VButton“5YTextField“8UImage“;ZStaticText“>\InternalLink“ATZoom_{{0, 0}, {276, 166}}    ;Pguö∞ƒŸ⁄€‹›Òˆ#().56;@AFRSXcdistyÉÑâïñõ™´∞∑∏Ω«»Õ”‘Ÿ‰Â͘¯˝F

iPhone模拟器plists无法通过python编辑还是这是一个损坏的文件?有办法解决这个问题吗?

I'm trying to modify the plist file at: /Volumes/MacintoshHD/Users/christian/Library/Application Support/iPhone Simulator/4.3.2/Library/Preferences/com.apple.Accessibility.plist

Here's my noob python script:

import plistlib
import os.path

#set path 
prefs_path = os.path.expanduser("~/Library/Application\ Support/iPhone\ Simulator/5.0/Library/Preferences/com.apple.Accessibility.plist")

#parse
prefs = plistlib.readPlist(prefs_path)

I get IOError: 2, 'No such file or directory'

If I remove the backslashes from the path I get ExpatError: 'not well-formed (invalid token): line 1, column 8'

Update

Ignacio Vazquez-Abram's answer suggests that the file is corrupted. It's still editable with Xcode and viewable with Quicklook. Also the simulator works fine.

When I open it in textmate all I see is this:

bplist00ÿ           
D   _ApplicationAccessibilityEnabled_VOTQuickNavEnabled_AccessibilityEnabled]ScreenCurtain_"VoiceOverTouchRotorItemsPreference_AXInspector.enabled_AXInspector.frame_AXInspectorEnabled         Ø"%(+.147:=@“   YRotorItemWEnabledYCharacter    “   TWord   “   TLine   “   VHeader “   TLink   “   [FormElement    “#  ZTableStart “&YListStart“)YLandmarks“,[VisitedLink“/^NonVisitedLink“2VButton“5YTextField“8UImage“;ZStaticText“>\InternalLink“ATZoom_{{0, 0}, {276, 166}}    ;Pguö∞ƒŸ⁄€‹›Òˆ#().56;@AFRSXcdistyÉÑâïñõ™´∞∑∏Ω«»Õ”‘Ÿ‰Â͘¯˝F

Are the iPhone simulator plists not editable by python or is this a corrupted file? Is there a way around this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沫离伤花2024-12-13 18:21:13

expat 错误意味着您已找到该文件,但其中有问题。打开文件并验证它没有被损坏。

编辑:

啊啊,这是一个二进制plist。是的,plistlib 无法处理这些。您需要 libplist 代替。

The expat error means that you've gotten to the file, but there's something wrong with it. Open the file and verify that it's not been corrupted.

EDIT:

Aaah, it's a binary plist. Yeah, plistlib can't handle those. You want libplist instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文