Monday, 15 April 2013

python - Meanings of percent sign(%) -



python - Meanings of percent sign(%) -

this question has reply here:

what % strings in python? 4 answers

can explain python code means.

v in m.getvars(): print('%s %g' % (v.varname, v.x))

the output print is

x 3 y 5

the '3' , '5' values of '(v.varname, v.x)' don't how knows print 'x' , 'y' , other uses there '%' other finding remainder.

the command

for v in m.getvars():

assigns list of var objects in model m variable v.

you can query various attributes of individual variables in list.

for example, obtain variable name , solution value first variable in list v, issue next command

print v.varname, v.x

you can type help(v) list of methods on var object

as others mentioned % place holders understand how code works, inspect model m

python

No comments:

Post a Comment