Suppose to run a block of code in script_mode and produce such data:
my_data = [1, 2, 3, 4] #please note this is output after running not data in script
Now I switch to work in console for debugging the code. I need to use the data produced just now, while cannot copy directly for avoiding the effect of gibberish. My solution is to pickle first in the script_mode and unpickle it in interactive_mode:
Codes with 5 commands:
Script Mode
import pickle
with open('my_data','wb') as file:
pickle.dump(my_data, file)
Interactive_mode:
import os, pickle
# change to the working directory
os.chdir('~\..\')
with open('my_data', 'rb') as file:
my_data = pickle.load(file)
# my_data is finally loaded in console
# then manipulate it on the console.
How to do it in less steps?