Current post is on how to remove non-printable characters from string.
Remove Non-printable function for ASCII String:
def remove_ascii_non_printable(str)
"""Removes Non-printable chars from ASCII String"""
return ''.join([ch for ch in str if ord(ch) > 31 and ord(ch) < 126 or ord(c) = = 9])
Remove Non-printable function for Unicode String:
def remove_unicode_non_printable(str)
"""Removes Non-printable chars from ASCII String"""
return ''.join([ch for ch in str if ord(ch) > 31 or ord(c) = = 9])
Appreciate your feedback via comments.
Thanks.