在Python中,data可以表示數(shù)據(jù)的不同形式、類型和結(jié)構(gòu)。以下是data在Python中的常見用法:
示例:
x = 5
y = "Hello"
示例:
mylist = [1, 2, 3, "four", 5.0]
print(mylist[0]) # 輸出: 1
mylist[3] = "four"
print(mylist) # 輸出: [1, 2, 3, "four", 5.0]
示例:
mydict = {"name": "John", "age": 25, "city": "New York"}
print(mydict["name"]) # 輸出: John
mydict["age"] = 26
print(mydict) # 輸出: {"name": "John", "age": 26, "city": "New York"}
示例:
mytuple = (1, "two", 3.0)
print(mytuple[1]) # 輸出: two
示例:
mystr = "Hello, World!"
print(mystr[7:]) # 輸出: World!
這些是data在Python中的常見用法,但還有其他更多的數(shù)據(jù)類型和數(shù)據(jù)結(jié)構(gòu)可以用來處理和操作數(shù)據(jù)。