Consider a simple string like '1.5 1e+05 test 4'. The format used in Python 2.7 to generate that string is '%f %e %s %i'. I want to retrieve a list of the form [1.5,100000,'test',4] from my input string knowing the string formatter. How can I do that (Python 2.7 or Python 3)?
Thanks a lot,
Ch.
import parse, format_string='{:1f} {:.2e} {:s} {:d}' pn=format_string.format(1.5,100000,'test',4) parsed=parse.parse(format_string, pn)Does not workparsemodule?type(parsed)isNoneTypeast.literal_eval?{:s}with{}. For some reason this works