For the following code,
import re
n = '.172..16.52.207,172.16.52.117'
s = re.split(',+|\.+',n)
print s
why is the first element of s
a blank, i.e. ''
?
For the following code,
import re
n = '.172..16.52.207,172.16.52.117'
s = re.split(',+|\.+',n)
print s
why is the first element of s
a blank, i.e. ''
?
The first element is everything between the beginning of the string and the first .
. There are no such characters, so it is ''
. n[2]
should be blank as well, because there is nothing between the second .
and the third.