0
私のPythonコードに問題があります。私はplistファイルを持っています。Pythonでplistファイルを解析する
のInfo.plist
<plist>
<dict>
<key>Apple Car Version</key>
<string>1.0</string>
<key>Last Backup Date</key>
<date/>
<key>Product Type</key>
<string>iPad2,5</string>
<key>Product Version</key>
<string>9.3.1</string>
</dict>
</plist>
私のPythonのコード:
import os
import plistlib
def main():
fileName=os.path.expanduser('Info.plist')
if os.path.exists(fileName):
pl=plistlib.readPlist(fileName)
if 'Product Version' in pl:
print('The aString value is %s\n' % pl['Apple Car Version'])
else:
print('There is no Apple Car Version in the plist\n')
else:
print('%s does not exist, so can\'t be read' % fileName)
if __name__ == '__main__':
main()
[OK]をので、私はいくつかのコードを書いたが、私は今、大きな問題に直面しています、私はそれを見つけました私のコードではありませんでしたが、plistのLast Backup Dateはエラーを引き起こします。私は文字列だけをparshことができる方法は、あなたが
またplistファイル形式の詳細についてのplist(5)https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man5/plist.5.htmlを参照してください – abeyer
OK答えを更新しました。構文エラーが発生しました:NameError:name 'load'が定義されていません。他のモジュールをインポートする必要はありますか? – UserBOBBED
私はいくつかのコードを書きましたが、現在はより大きな問題に直面しています。私のコードではなく、plistのLast Backup Dateが原因でエラーが発生しました。 –
UserBOBBED