Reading after a symbol..

Pratik Khemka pratikkhemka at hotmail.com
Tue Oct 12 22:48:17 CEST 2010


Say :  line = abcdabcd#12 adssda

 

index = line.find('#')

num = line[index:index+2]

 

num will now be 12. 

 

Likewise I want to read the number after the '#' and store it in num. The problem is that the number can be a 1/2/3/4 digit number. So is there a way in which I can define num so that it contains the number after '#' irrespective of how many digits the number is. Because the problem is that the above code will not work for scenarios when the number is  not 2 digits..

 

Thanks,

Pratik
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101013/c9bbbb37/attachment.html>


More information about the Python-list mailing list