parser.add_option('-p', '--pickled_data_path', dest='pickled_data_path',
    type='string', help='Path to the file containing pickled data.')
parser.add_option('-j', '--json_data_path', dest='json_data_path', type=
    'string', help='Path to where the json data should be saved.')
opts, args = parser.parse_args()
if opts.pickled_data_path:
    unpickled_data = cPickle.loads(open(opts.pickled_data_path).read())
else:
    unpickled_data = cPickle.loads(sys.stdin.read())
if opts.json_data_path:
    open(opts.json_data_path, 'w').write(json.dumps(unpickled_data))
else:
    pass
Десериализация Python Pickle из PHP?