Horje
can you edit string.punctuation Code Example
can you edit string.punctuation
>>> from string import punctuation
>>> from re import sub
>>> 
>>> string = "\Fred-Daniels!"
>>> translator = str.maketrans('','', sub('\-', '', punctuation))
>>> string
'\\Fred-Daniels!'
>>> string = string.translate(translator)
>>> string
'Fred-Daniels'
can you edit string.punctuation
>>> name = '\\test-1.'
>>> valid_characters = 'abcdefghijklmnopqrstuvwxyz1234567890- '
>>> filtered_name = ''.join([ x for x in name if x.lower() in valid_characters ])
>>> print(filtered_name)
test-1




Python

Related
remove too short strings from a list python Code Example remove too short strings from a list python Code Example
how to get input from user in pyqt5 Code Example how to get input from user in pyqt5 Code Example
random forrest plotting feature importance function Code Example random forrest plotting feature importance function Code Example
how to install from url in python Code Example how to install from url in python Code Example
text adventure in python Code Example text adventure in python Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7