Created
October 14, 2016 03:21
-
-
Save tomatoiscoding/51e5bfa054f83a0e1e3406042d7c6ddb to your computer and use it in GitHub Desktop.
some tricks for regular expression with python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # this a list in python,\n represents newline | |
| a = ['1', '2', '3', '4', '\n'] | |
| # convert list to string | |
| a = ''.join(a) | |
| # delete '\n' | |
| a = a.rstrip('\n') | |
| # convert string to integer | |
| a = map(int, a) | |
| # splitline | |
| a = ['1', '2', '3', '4', '\n', '5', '6', '7', '8'] | |
| a = a.splitlines() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment