I need to convert tuples into an array of strings with those tuples.
So this:
(A, "DEFAULT"), (B, "a$"), (C, "aa$"), (D, "(a|b|c)*aab(a|b|c)*")`
Should become this.
['(A, "DEFAULT")', '(B, "a$")', '(C, "aa$")', '(D, "(a|b|c)*aab(a|b|c)*")']
string = '(A, "DEFAULT"), (B, "a$"), (C, "aa$"), (D, "(a|b|c)*aab(a|b|c)*")'
split = string.split('),')
result = []
for i in range(len(split)):
if i != len(split) - 1:
text = split[i] + ')'
result.append(text)
else:
result.append(split[i])
Got it!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.