tomatoiscoding
10/14/2016 - 3:21 AM

some tricks for regular expression with python

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()