scanf string in python

lehrig lehrig at t-online.de
Fri Jul 18 01:45:59 EDT 2003


lehrig wrote:

> I have a string which is returned by a C extension.
> 
> mystring = '(1,2,3)'
> 
> HOW can I read the numbers in python ?

Now I have done it like this:
  tmp = mystring[1:-1]
  tmplist = string.split(tmp,',')
  x = int(tmplist[0])
  y = int(tmplist[1])
  z = int(tmplist[2])

But there should be a more convenient solution.




More information about the Python-list mailing list