Skip to content

Instantly share code, notes, and snippets.

@wynnzen
Created May 5, 2014 02:40
Show Gist options
  • Save wynnzen/ee173d69f7a687cf9d1e to your computer and use it in GitHub Desktop.
Save wynnzen/ee173d69f7a687cf9d1e to your computer and use it in GitHub Desktop.
清除换行符
#1.正则
strip("\r\n") #方法2
"".join(s.strip()) #方法3
#方法3的原理
'''
Return a list of the words of the string s.
If the optional second argument sep is absent or None,
the words are separated by arbitrary strings of whitespace characters
(space, tab, newline, return, formfeed). If the second argument sep is present and not None,
it specifies a string to be used as the word separator.
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment