在Python中,可以使用以下几种形式来存储数据:
x = 10
y = 3.14
name = "John"
numbers = [1, 2, 3, 4, 5]
fruits = ["apple", "banana", "orange"]
mixed_list = [1, "apple", True, 3.14]
person = ("John", 25, "male")
point = (2, 3)
student = {"name": "John", "age": 25, "gender": "male"}
fruits = {"apple", "banana", "orange"}
numbers = {1, 2, 3, 4, 5}
# 写入文件
with open("data.txt", "w") as file:
file.write("Hello, World!")
# 读取文件
with open("data.txt", "r") as file:
data = file.read()
print(data)
这些是Python中常用的数据存储形式,可以根据需求选择合适的形式来存储数据。