Remove Text:u From Strings In Python
I am using xlrd library to import values from excel file to python list. I have a single column in excel file and extracting data row wise. But the problem is the data i am getting
Solution 1:
Iterate over items and remove extra characters from each word:
s=[]
for x in list:
s.append(x[7:-1]) # Slice from index 7 till lastindex - 1
Solution 2:
If that's the standard input list you have, you can do it with simple split
[s.split("'")[1] for s inlist]
# if your string itself has got "'" in between, using regex is always safeimport re
[re.findall(r"u'(.*)'", s)[0] for s inlist]
#Output#['__string__', '__string__']
Post a Comment for "Remove Text:u From Strings In Python"