Generic string import like in strptime?

A

Andre

Hi there

Is there a function like strptime, which takes a string and converts it
into an array depending on a format string I provide. Like:[3456,'blub','blib',0.9]


Many thanks

Andre
 
N

Neil Cerutti

Hi there

Is there a function like strptime, which takes a string and converts it
into an array depending on a format string I provide. Like:[3456,'blub','blib',0.9]

No, not in the standard distribution of Python.

In Python, you're expected to use appropriate string methods, or hold
your nose and drag out the re module. There are some scanf-like
libraries for Python available on the net, e.g.,
http://hkn.eecs.berkeley.edu/~dyoo/python/scanf/. None of them have
become popular enough with Python users to make it into the standard
distribution.

An excellent tool that can be used in these cases is pyparsing, which
is also not in the standard distribution.
http://pyparsing.wikispaces.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top