Skip to content

Instantly share code, notes, and snippets.

@chris-zh
Created March 15, 2016 06:02
Show Gist options
  • Save chris-zh/2051b1cd2dc0b055ba8a to your computer and use it in GitHub Desktop.
Save chris-zh/2051b1cd2dc0b055ba8a to your computer and use it in GitHub Desktop.
Python去除字符串外的空格
" xyz ".strip() # returns "xyz"
" xyz ".lstrip() # returns "xyz "
" xyz ".rstrip() # returns " xyz"
" x y z ".replace(' ', '') # returns "xyz"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment