Python Assign value to variable during condition in while Loop
问题 A simple question about Python syntax. I want to assign a value from a function to a variable during the condition for a while loop. When the value returned from the function is false, the loop should break. I know how to do it in PHP. while (($data = fgetcsv($fh, 1000, ",")) !== FALSE) However when I try a similar syntax in Python I get a syntax error. 回答1: You cannot use assignment in an expression. Assignment is itself a statement, and you cannot combine Python statements. This is an