Before use stript() we can see the space
>>> ipaddr=' 10.255.1.10/24 '
>>> print ipaddr
10.255.1.10/24
After using strip()
>>> ipaddr.strip()
'10.255.1.10/24'
this is very usefull when you wanna use startswith() or endswith(). because those won't work when a space inside it. let's try :
>>> ipaddr
' 10.255.1.10/24 '
>>>
>>> ipaddr.startswith('10')
False
>>>
see that!
Now we try to use strip() first we just create a variable for new data :
>>> ipaddrstrip = ipaddr.strip()
>>> ipaddrstrip
'10.255.1.10/24'
>>> ipaddrstrip.startswith('10')
True
it's work!
Tulis komentar anda... Conversion Conversion Emoticon Emoticon