Skip to content

Instantly share code, notes, and snippets.

@tomatoiscoding
Created October 14, 2016 03:21
Show Gist options
  • Select an option

  • Save tomatoiscoding/51e5bfa054f83a0e1e3406042d7c6ddb to your computer and use it in GitHub Desktop.

Select an option

Save tomatoiscoding/51e5bfa054f83a0e1e3406042d7c6ddb to your computer and use it in GitHub Desktop.
some tricks for regular expression with python
# 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