Meaning of using commas and underscores with Python assignment operator?
问题 Reading through Peter Norvig's Solving Every Sudoku Puzzle essay, I've encountered a few Python idioms that I've never seen before. I'm aware that a function can return a tuple/list of values, in which case you can assign multiple variables to the results, such as def f(): return 1,2 a, b = f() But what is the meaning of each of the following? d2, = values[s] ## values[s] is a string and at this point len(values[s]) is 1 If len(values[s]) == 1 , then how is this statement different than d2 =