向上取整
# 向上取整
import math
number = 5.7
rounded_up = math.ceil(number)
print(rounded_up) # Output: 6
大根堆
import heapq
ll=[1,4,2,3,5]
heapq.heapify(ll)# 变成小根堆
max_heap = [-i for i in ll]
heapq.heapify(max_heap)
print([-i for i in max_heap])# 输出大根堆 [5, 4, 2, 1, 3]
defaultdict()
from collections import defaultdict
# Create a defaultdict with default value as a list
groups = defaultdict(list)
# Add elements to the defaultdict
groups['group1'].append('Alice')
groups['group1'].append('Bob')
groups['group2'].append('Charlie')
groups['group2'].append('David')
print(groups)
# output: {'group1': ['Alice', 'Bob'], 'group2': ['Charlie', 'David']}