<｜begin▁of▁sentence｜>### Instruction:
Given a MultiGraph with multiple weighted edges between the same pairs of nodes (e.g., ('A', 'B') with weights 1 and 2), how can you access and print the weights of all edges between those nodes using NetworkX's MultiAdjacency view?
### Response:
import networkx as nx

# Create a MultiGraph
G = nx.MultiGraph()

# Add multiple edges between the same pairs of nodes
G.add_edge('A', 'B', key='first', weight=1)
G.add_edge('A', 'B', key='second', weight=2)

# Access edges using a MultiAdjacency view
for n, nbrs in G.adjacency():
    for nbr, keydict in nbrs.items():
        for key, eattr in keydict.items():
            weight = eattr['weight']
            print(f'Edge from {n} to {nbr} with key {key} has weight {weight}')
<|EOT|>
