Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- user_input = "This\nstring has\tsome whitespaces...\r\n"
- character_map = {
- ord('\n') : ' ',
- ord('\t') : ' ',
- ord('\r') : None
- }
- user_input.translate(character_map)
- # Output: 'This string has some whitespaces... '
Advertisement
Add Comment
Please, Sign In to add comment