Skip to main content
added 149 characters in body
Source Link
Vladimir
  • 6.9k
  • 2
  • 36
  • 40

As far as I know, the most pythonic/efficient method would be:

import string filtered_string = filter(lambda x: x in string.printable, myStr) 

Note: string.printable - String of ASCII characters which are considered printable.

Here is example for unicode:

def remove_non_printable(value: str) -> str: return ''.join(i for i in value if i.isprintable()) 

As far as I know, the most pythonic/efficient method would be:

import string filtered_string = filter(lambda x: x in string.printable, myStr) 

Note: string.printable - String of ASCII characters which are considered printable.

As far as I know, the most pythonic/efficient method would be:

import string filtered_string = filter(lambda x: x in string.printable, myStr) 

Note: string.printable - String of ASCII characters which are considered printable.

Here is example for unicode:

def remove_non_printable(value: str) -> str: return ''.join(i for i in value if i.isprintable()) 
added 91 characters in body
Source Link
Vladimir
  • 6.9k
  • 2
  • 36
  • 40

As far as I know, the most pythonic/efficient method would be:

import string filtered_string = filter(lambda x: x in string.printable, myStr) 

Note: string.printable - String of ASCII characters which are considered printable.

As far as I know, the most pythonic/efficient method would be:

import string filtered_string = filter(lambda x: x in string.printable, myStr) 

As far as I know, the most pythonic/efficient method would be:

import string filtered_string = filter(lambda x: x in string.printable, myStr) 

Note: string.printable - String of ASCII characters which are considered printable.

added 2 characters in body
Source Link
zmo
  • 24.9k
  • 4
  • 58
  • 91

As far as I know, the most pythonic/efficient method would be: import string

import string filtered_string = filter(lambda x: x in string.printable, myStr) 

As far as I know, the most pythonic/efficient method would be: import string

filtered_string = filter(lambda x: x in string.printable, myStr) 

As far as I know, the most pythonic/efficient method would be:

import string filtered_string = filter(lambda x: x in string.printable, myStr) 
Source Link
William Keller
  • 5.4k
  • 1
  • 28
  • 22
Loading