[Tutor] problem with stirng.find

Isr Gish isrgish at fastem.com
Tue Nov 23 03:35:40 CET 2004


Fabian von Berlepsch"<pub at berlepsch.de> wrote:
   >I am using pyserail for reading the serial port
   >I get the following string (print s) :
   >"\xffS!AAAA\xfe0.005\r\n\xffS!AAAA\xfe0.005\r\n"
   >
   >When I do 
   >
   >Import string

You don't need to import string. You cAn do the following.

>>> s = 'Hello world!'
>>> s.find('w')

 IOW most of the functions in the string module, are now available as string methods.

   >Print string.find(s,"S!A")
   >
   >It prints: 11

The find method (function) returns the index where the substring was found. I'm not sure what you expected to happen.

All the best,
Isr


   >
   >What is happening here?
   >
   >Thank you very much for any advice!
   >
   >Yours Fabian
   >
   >
   >_______________________________________________
   >Tutor maillist  -  Tutor at python.org
   >http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list