摘要:
sequence[start:stop:step] start 是切片开始的位置(包含该位置的元素)。 stop 是切片结束的位置(不包含该位置的元素)。 step 是步长(即两个元素之间的间隔),默认值为1。 1.基本切片 my_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 阅读全文
posted @ 2025-03-16 18:03
起名字太难0123
阅读(20)
评论(0)
推荐(0)
摘要:
list_of_dicts = [ {'key': 'value1', 'other_key': 'other_value1'}, {'key': 'value2', 'other_key': 'other_value2'}, {'key': 'value3', 'other_key': 'othe 阅读全文
posted @ 2025-03-16 17:44
起名字太难0123
阅读(12)
评论(0)
推荐(0)
摘要:
append()在列表尾部添加一个元素,这个元素可以是任意数据类型(列表和任意数据类型之间操作) my_list = [1, 2, 3] my_list.append(4) print(my_list) # 输出: [1, 2, 3, 4] my_list.append([5, 6]) print( 阅读全文
posted @ 2025-03-16 17:33
起名字太难0123
阅读(14)
评论(0)
推荐(0)
摘要:
列表推导式 data = [ {"key": "value", "name": "Alice", "age": 30}, {"key": "other_value", "name": "Bob", "age": 25}, {"key": "value", "name": "Charlie", "ag 阅读全文
posted @ 2025-03-16 17:26
起名字太难0123
阅读(14)
评论(0)
推荐(0)

浙公网安备 33010602011771号