问题
I am working with a repository where there is a pickle file that shows the names of the videos in the dataset and the number of frames of each video.
(dp0
S'v_Lunges_g07_c01.avi'
p1
I248
sS'v_Haircut_g18_c04.avi'
p2
I263
sS'v_Bowling_g21_c03.avi'
p3
I179
sS'v_FrontCrawl_g04_c04.avi'
p4
I328
sS'v_Biking_g15_c05.avi'
p5
I239
sS'v_Swing_g08_c03.avi'
I289
s.
With some help from StackOverflow I learnt that I can get a similar file (text editor readable) using pickle.dump(obj, protocol=0)
However, I fail to find information about the format used. I assume the S- corresponds to videonames and I248, for example corresponds to Integer-value:248 (no of frames). When I try a mini sample of a dictionary of Strings and integers however, I get this:
(dp0
VLaika
p1
L16L
sVBarco
p2
L12L
sVFilou
p3
L8L
sVLuna
p4
L5L
sVBalou
p5
L9L
sVSkippy
p6
L10L
sVOzzy
p7
L3L
s.
I define the dictionary as such: dogs_dict = { "Ozzy": int(3), "Filou": int(8), "Luna": int(5), "Skippy": int(10), "Barco": int(12), "Balou": int(9), "Laika": int(16) }
How can I define the format that will be output to pickle file if casting them is not working?
回答1:
It seems it was because I was using Python3, with Python2 I get the format I intend to.
来源:https://stackoverflow.com/questions/55142214/how-can-i-define-the-format-that-will-be-output-string-integer-etc-to-pickle