Use string formatting in Jython

1.3k views Asked by At

I am new in Jython.. I want to use the string formatting str.format() in Jython (look here).

If I try to use it like this:

testText = 'This is a {word}'

and later on

str.format(testText, word='test!')

the exception text is:

Error: exceptions.AttributeError instance of 'org.python.core.PyReflectedFunction' has no attribute 'format'

What do I have to add in the imports/classpath or anywhere?!

Thanks for your help!!

Kind regards

1

There are 1 answers

0
Sairungrawee Navamachiti On

Try this:

print "%(map_1)s  %(map_2)s" % {'map_1':'Hello','map_2':'World'}