python is recommended for the implementation of of without whitespace and newline

  • 2020-05-19 05:10:20
  • OfStack

1. Remove Spaces

strip()

" xyz ".strip() # returns "xyz"
" xyz ".lstrip() # returns "xyz "
" xyz ".rstrip() # returns " xyz"
" x y z ".replace(' ', '') # returns "xyz"


2. Replace replace (" space ", "")

Replace the string in front with replace("\n", "")


Related articles: