[英]How can I remove parentheses (both side) from tuple?
This is my script.py:这是我的脚本.py:
from itertools import product
A = input().split()
B = input().split()
li1 = []
li2 = []
for i in A:
li1.append(int(i))
for j in B:
li2.append(int(j))
result = product(li1,li2)
print(tuple(result))
it gives me result like this ((1, 3), (1, 4), (2, 3), (2, 4))
它给了我这样的结果
((1, 3), (1, 4), (2, 3), (2, 4))
But I want to result like this (1, 3) (1, 4) (2, 3) (2, 4)
但我想得到这样的结果
(1, 3) (1, 4) (2, 3) (2, 4)
How can I do this?我怎样才能做到这一点?
Unpack with a *
用
*
解压
print(*result)
This will use the contents of the iterable as arguments to print()
, instead of the whole thing as a single argument.这将使用可迭代的内容作为 arguments 到
print()
,而不是将整个内容作为单个参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.