The str.translate() method accepts a table of codepoints (numerical value of a character) mapped to another character or codepoint. Map to None for characters that have to be deleted. You can use the ord() built-in function to get the codepoint of characters. Or, you can use the str.maketrans() method to generate the mapping for you.