SnK
SnK

Reputation: 1004

How to read text from .plist file?

My iPhone app has App Version number in Info.plist. I need a python script to read the App Version from it and print both?

I have printed the plist file. Below is the code

for file in os.walk(FOLDERPATH):
    inFile = open('Info.plist', 'rt')
    for line in inFile:
print(inFile.read())

Upvotes: 6

Views: 14567

Answers (3)

DaveL17
DaveL17

Reputation: 2013

Updated plistlib example for Python3:

import plistlib
file_name = "/Users/Dave/Info.plist"
with open(file_name, 'rb') as infile:
    plist = plistlib.load(infile)
print(plist["aKey"])

Upvotes: 2

user2665694
user2665694

Reputation:

I found this. I believe its what you're looking for. Hope it helps! http://docs.python.org/dev/library/plistlib.html

Upvotes: 10

user634175
user634175

Reputation:

Slightly adapted plistlib example:

import plistlib
pl = plistlib.readPlist("Info.plist")
item = pl["aKey"]

Upvotes: 10

Related Questions