user715578
user715578

Reputation: 467

Save python plistlib data

how do I save the output I get for this program(as a variable), instead of it being printed?

import plistlib, time
import plistlib as pl
p=pl.readPlist("Restore.plist")
print p["ProductType"]#I want this to be outputted as a variable, such as 'x' instead of   python printing it.
print p["ProductVersion"]
print p["ProductBuildVersion"]

Upvotes: 0

Views: 342

Answers (2)

Spencer Rathbun
Spencer Rathbun

Reputation: 14910

It's already a variable. Namely, it's part of the variable p. If you want to assign it to another variable use the = sign like on line 3 of your code.

Upvotes: 0

RickyA
RickyA

Reputation: 16029

something like this?

outputfile = open('output.plist', 'w')
outputfile.write(p["ProductVersion"])
outputfile.close()

Upvotes: 1

Related Questions