-2

I tried to store array values in python but after inserting values I close the IDE and open it prints the array values null. How can we store dynamic array values permanently in python it's like load and write values from a file.......

Arun Das
  • 63
  • 1
  • 4
  • write a file and don't use the IDE to store data – 0TTT0 Oct 21 '17 at 16:07
  • What you did may be obvious to you, but you need to be explicit with us. *How* did you try to store them? If your question is how to write to and read from a file, it has surely been asked before. – Reti43 Oct 21 '17 at 16:08
  • how can we permanently store array values in python??? – Arun Das Oct 21 '17 at 16:12
  • There are many options for writing something to a file, but the cleanest or most appropriate depends on what kind of values you have. Is it an numpy array or list? Are your values numbers, strings or objects? – Reti43 Oct 21 '17 at 16:34

2 Answers2

0

You could use

  • json
  • pickle

for permanent storage.

if STORAGEFILE EXISTS:
  Var = STORAGEFILE_CONTENT
else:
  Var = currentVal
ON_EXIT:
  Update Var to STORAGEFILE
Fuji Komalan
  • 1,979
  • 16
  • 25
0

The easiest way is to write the array values to a txt-file. Then you can close your IDE and later open it and get the array from the txt-file.

Writing a list to a file with Python

PederBG
  • 118
  • 1
  • 2
  • 11