How to return more than one value from a function in Python? [duplicate]
问题 This question already has answers here : What's the best way to return multiple values from a function in Python? (5 answers) Closed 6 years ago . How to return more than one variable from a function in Python? 回答1: You separate the values you want to return by commas: def get_name(): # you code return first_name, last_name The commas indicate it's a tuple, so you could wrap your values by parentheses: return (first_name, last_name) Then when you call the function you a) save all values to