[英]Set each number from input to its own variable
How can I set each number from input to its own variable?如何将输入中的每个数字设置为其自己的变量?
code:代码:
import sys
for line in sys.stdin:
print(line)
input:输入:
(25,6) (25,10)
I want我想
x1=25
y1=6
x2= 25
y2 =10
You can use a regular expression to extract the numbers from the input.您可以使用正则表达式从输入中提取数字。
for line in sys.stdin:
match = re.search(r'\((\d+),(\d+)\)\s*\((\d+),(\d+)\)', line)
if match:
x1, y1, x2, y2 = map(int, match.groups())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.