且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在python中进行简单的用户输入?

更新时间:2023-11-25 20:12:22

您可以使用 c5> 将用户输入从字符串转换为浮点数:

You can use the input() function to prompt the user for input, and float to convert the user input from a string to a float:

x1 = float(input("x1: "))
y1 = float(input("y1: "))
x2 = float(input("x2: "))
y2 = float(input("y2: "))

如果您使用的是python 2,请使用 raw_input() 代替.

If you're using python 2, use raw_input() instead.