Removing Spaces And Non-printable Character In Python
I am working with xml file using lxml etree xpath method. My code is from lxml import etree File='c:\file.xml' doc=etree.parse(File) alltext = doc.xpath('descendant-or-self::text()
Solution 1:
If you don't mind to do it using regex
:
import re
clump = re.sub(r'[\n\t]+', ' ', clump)
If you want to put any other characters to remove, just place those inside the []
Post a Comment for "Removing Spaces And Non-printable Character In Python"