2024-05-15 07:46:01 发布
网友
我目前正在使用Plistlib模块来读取Plist文件,但当涉及到二进制Plist文件时,我目前有一个问题。
我想把数据读入一个字符串,以便以后分析/打印等。我想知道他们是否在不使用plutil函数的情况下读入二进制Plist文件并将二进制文件转换成XML?
谢谢你的帮助和提前的时间。
Biplisthttps://github.com/wooster/biplist可通过简易安装或pip获得。
尽管您没有指定plutil,但使用它的工作解决方案可能对其他人有用,因为它已预先安装在Mac上:
plutil
import json from subprocess import Popen, PIPE def plist_to_dictionary(filename): "Pipe the binary plist through plutil and parse the JSON output" with open(filename, "rb") as f: content = f.read() args = ["plutil", "-convert", "json", "-o", "-", "--", "-"] p = Popen(args, stdin=PIPE, stdout=PIPE) out, err = p.communicate(content) return json.loads(out) print plist_to_dictionary(path_to_plist_file)
您可以使用工具plutil(来自http://www.libimobiledevice.org/的libplist)将二进制文件转换为xml plist文件(反之亦然)。
Biplisthttps://github.com/wooster/biplist可通过简易安装或pip获得。
尽管您没有指定
plutil
,但使用它的工作解决方案可能对其他人有用,因为它已预先安装在Mac上:您可以使用工具plutil(来自http://www.libimobiledevice.org/的libplist)将二进制文件转换为xml plist文件(反之亦然)。
相关问题 更多 >
编程相关推荐