assign output of print to a variable in python

前端 未结 6 1421
心在旅途
心在旅途 2021-01-15 01:41

i want to know how to assign the output of print to a variable.

so if

mystring = \"a=\\\'12\\\'\"

then

print mys         


        
6条回答
  •  心在旅途
    2021-01-15 02:24

    for more of an explanation: i have a list of strings i got from a a comment line of a data file. it looks like this:

    "a='0.015in' lPrime='0.292' offX='45um' offY='75um' sPrime='0.393' twistLength='0'",
     "a='0.015in' lPrime='0.292' offX='60um' offY='75um' sPrime='0.393' twistLength='0'",
     "a='0.015in' lPrime='0.292' offX='75um' offY='75um' sPrime='0.393' twistLength='0'",
     '']
    

    i want to put the values into some structure so i can plot the various things versus any variabls so the list is a legend basically, and i want to plot functions of the traces versus variables given in teh legend.

    so if for each entry i have a trace, then i may want to plot max(trace) vs offX for a series of a values.

提交回复
热议问题