Issue
I tried to use environment variables in order to save data. I tried to save the variables with os.environ, but in linux the variables stay empty, after executing this small script:
import os
os.environ['LD_LIBRARY_PATH'] = "my_path"
exit()
dave@dave-ThinkPad-L13-Gen-2:~/PythonProjects/USAImport$ echo $LD_LIBRARY_PATH
How to set environment variables in Python?
Which is the fastest way to persist data. I just have to save a cookie.
Solution
Environment variables is not way to save data, but a way, how to configure your application - it survive fork
and exec
operation.
To easily persist your data, I would recommend you using YAML or JSON file. Here is a nice answer, which helps you to do it on few lines.
data
in the answer is dictionary. If you want a shortest possible way, how to persist data, you have to premake an empty JSON file with the right structure, so you can easily read on the first run without defining it in the code.
Answered By - Přemysl Šťastný
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.