编写一个函数,它接受给定格式的字符串,返回给定以下格式的列表
input: "[(694, 104), (153, 236), (201, 106), (601, 427)]"
o/p:
(694, 104)
(153, 236)
(201, 106)
(601, 427)
我已经编写了以下代码,但没有得到正确的输出:
def convertor(string):
result = (string.split(" "))[0]
return result
string1 = "[(694, 104), (153, 236), (201, 106), (601, 427)]"
print(convertor(string1.replace("[","").replace("]","")))