Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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'
Comment

can you edit string.punctuation

>>> name = '	est-1.'
>>> valid_characters = 'abcdefghijklmnopqrstuvwxyz1234567890- '
>>> filtered_name = ''.join([ x for x in name if x.lower() in valid_characters ])
>>> print(filtered_name)
test-1
Comment

PREVIOUS NEXT
Code Example
Python :: max of 2d array python 
Python :: print items in object python 
Python :: floyd triangle python 
Python :: Import "dj_database_url" could not be resolved Pylance 
Python :: create np nan array 
Python :: discord.py how to give a user a role 
Python :: np replace nan 
Python :: pandas read_csv multiple separator 
Python :: json load python 
Python :: append to csv python 
Python :: django expressionwrapper example 
Python :: how to get user ip in python 
Python :: ec2 upgrade python 3.7 to 3.8 
Python :: pygame.set_volume(2.0) max volume 
Python :: isprime in python 
Python :: how to download file in python 
Python :: pandas fill missing values with average 
Python :: convert list to binary python 
Python :: python datetime into 12-hour format 
Python :: plot confidence interval matplotlib 
Python :: python strftime utc offset 
Python :: check if number in range 
Python :: selenium python chrome path 
Python :: python snake game 
Python :: csv write without new line 
Python :: remove n from string python 
Python :: first day of the month python 
Python :: python check folder exist 
Python :: replace error with nan pandas 
Python :: python numpy kurtosis 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =