Question on how to store Python variable values

Asked 2 years ago, Updated 2 years ago, 15 views

def search_f(): #search function
    search_value = int(input("""
    To search for a punishment name by name 1
    If you want to see the list of names of students, you can choose 2
    If you want to see the list of punishments, please enter 3 "") #What features do you want to use?
    if search_value == 1:
      s_name = input ("Please enter your school year_name")
      print(i[s_name])
    elif search_value == 2:
      print(i.keys())
    elif search_value == 3:
      print(i.values())

How do I save the values in i.values when I do this? If you write f = open, f.write, it's saved as a notepad, but the value of the Python variable is the same I hope that it's maintained

python

2022-09-20 14:56

1 Answers

Use the pickle module as a way to serialize and store objects in Python.

https://wayhome25.github.io/cs/2017/04/04/cs-04/


2022-09-20 14:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.