Apr-05-2020, 05:48 PM
(Apr-05-2020, 05:36 PM)buran Wrote: please, show real code, don't explain what you have or what you expect. As of now it's not clear neither what you have, or what you want.
From what i get - the way you write is not correct (i.e. you will get also square brackets in the file).
For reading csv file - look at csv module or read the line and split at ','.
Note in any case you will need to convert each element to int, because they will come as str from the file.
Thanks. I understand the importance of using code quotations and will do so from now on. Yes I did get square brackets in the file which is what I thought I had said. Anyway I found the use of pickle to do what I needed.
import pickle add_val = 110 att_val = 7 val_val = 125 val = [add_val, att_val, val_val] print(val) with open('test', 'wb') as f: pickle.dump(val, f) with open('test', 'rb') as f: z = pickle.load(f) print(z) print('add_val = ', z[0]) print('att_val = ', z[1]) print('val_val = ', z[2])And here is the output
>>> %Run pickletest.py [110, 7, 125] [110, 7, 125] add_val = 110 att_val = 7 val_val = 125