0

Python data

Hi, I wish to make an AI that memorize a data insered by the user and remember them when you close and re-open too. Can someone help me?

10th Dec 2019, 7:21 AM
Mr. Scratch
Mr. Scratch - avatar
6 odpowiedzi
10th Dec 2019, 7:55 AM
Seb TheS
Seb TheS - avatar
+ 1
2 ways: open and read it, then pass it as string in exec function. import it
10th Dec 2019, 8:06 AM
Seb TheS
Seb TheS - avatar
0
You would need to store the data in files.
10th Dec 2019, 7:50 AM
Seb TheS
Seb TheS - avatar
0
How can I do it? Thanks
10th Dec 2019, 7:51 AM
Mr. Scratch
Mr. Scratch - avatar
0
Thanks! But if the program save into a file a command, like print("Hello World"), how can it run in a program?
10th Dec 2019, 7:57 AM
Mr. Scratch
Mr. Scratch - avatar
0
After you know how you can handle files, to save data in text you should create a logic for it. For example to store list [160, 205, 639] in a text file you could create a mechanism where you separate each item by space: "160 205 639" and write it in file as string. And to read that data you should open the file again and do the reverse. But doing that by saving Python file: "[160, 205, 639]" and getting the data by running the file is not recommended.
10th Dec 2019, 10:28 AM
Seb TheS
Seb TheS - avatar