How to split tuple with parentheses in Python?
问题 I have built-in tuple which looks like (u,v) . They are generated by Networkx and they show links in a graph. I make a list out of the called link_list . I have to split the tuple such that the outcome would be: u , v I tried divmod but it doesn't give the right answer. for link in link_list: u,v = divmod(*link) print u,v 回答1: Simple: for link in link_list: u, v = link print u, v It's called sequence unpacking. 回答2: you can get the tuple into individual variables in the for statement as