Background:
code.interact()
that created an interactive shellIssue: For some reason, the shell hang and cannot finish
Question: Is it possible to retrieve the variable that saved in the interactive shell?
Ctrl+Z and Kill the process usually will fix the hang issue but I have to rerun it again and lost some already generated information.
Define a dict data={}
before starting the interactive session, then pass it as a local code.interact(local={'data':data})
. Save your data in that dict, and all changes will be available after exiting the interactive session.
This works because interact
doesn't actually start a new process/interpreter.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.