def convert(in_str):
result = []
current_tuple = []
for token in in_str.split(","):
number = int(token.replace("(","").replace(")", ""))
current_tuple.append(number)
if ")" in token:
result.append(tuple(current_tuple))
current_tuple = []
return result
4条答案
按热度按时间nfs0ujit1#
字符串
dgiusagp2#
不带ast或eval:
字符串
ct2axkht3#
无AST:
字符串
nwlqm0z14#
只是为了完整:soulcheck的解决方案,它满足了原始海报的要求,以避免ast.literal_eval:
字符串