How can multiple numbers be entered in one line in Python?
In Python, you can use the input() function to receive input from the user. If you want to input multiple numbers in one line, you can use the split() function to split the input string into a list.
Below is an example code:
nums = input("请输入多个数(以空格分隔):").split()
# 将输入的字符串转换为整数列表
nums = [int(num) for num in nums]
print(nums)
By running the above code, users will be prompted to input multiple numbers separated by spaces. The program will store these numbers in a list and print them out.
Please note that the input numbers will be treated as strings. If you need to convert them to other types (such as integers or floating-point numbers), you should use the appropriate type conversion functions (such as int() or float()).