python remove text in brackets code example
Example 1: how to remove text in brackets of python
>>> import re
>>> x = "This is a sentence. (once a day) [twice a day]"
>>> re.sub("[\(\[].*?[\)\]]", "", x)
'This is a sentence. '
Example 2: how to remove brackets from list in python text file
res = str(test_list)[1:-1]