Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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.  '
Comment

python remove brackets from string

>>> import re
>>> my_str = 'Hello [World]'
>>> re.sub(r'[[]]', r'', my_str)
'Hello World'
Comment

how to remove brackets from list in python text file

res = str(test_list)[1:-1]
Comment

PREVIOUS NEXT
Code Example
Python :: install pipenv on windows 
Python :: python - convert a column in a dataframe into a list 
Python :: create pandas dataframe with random numbers 
Python :: tf 1 compatible colab 
Python :: python install command in linux 
Python :: pandas convert index to column 
Python :: sorting rows and columns in pandas 
Python :: numpy get index of nan 
Python :: pandas uniqe values in the columns 
Python :: cv2.imwrite save to folder 
Python :: django add media 
Python :: how to create dataframe in python 
Python :: pretty print pandas dataframe 
Python :: python check if there is internet 
Python :: pygame draw line 
Python :: python pyodbc install 
Python :: string to datetime 
Python :: print current time hours and minutes in python 
Python :: How to print list without for loop python 
Python :: keras import optimizer adam 
Python :: How do I set Conda to activate the base environment by default? 
Python :: dice simulator in python 
Python :: pandas_datareader 
Python :: tensot to numpy pytorch 
Python :: pytesseract tesseract is not installed 
Python :: pandas convert to 2 digits decimal 
Python :: sum of all nan values pandas 
Python :: shift elements in list python 
Python :: how to open file in BeautifulSoup 
Python :: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =