Python string formatting displays issue -


running python 2.6

i need make api call jenkins using following format:

j.build_job('my job name', {'branch_name': 'xyz', 'version': '12.2' })

i need pass in 2 variables branch , version upon displaying output test, doesn't insert branch name first field.

('my job name', {'branch_name': '{0}', 'version': '12.2'})

code below:

branch="xyz" version="12.2"  print ('my job name', {'branch_name': '{0}', 'version': '{1}'.format(branch,version) }) 

try it.

branch="xyz" version="12.2"  print ('my job name', {'branch_name': '{0}'.format(branch) , 'version': '{0}'.format(version) }) # ('my job name', {'branch_name': 'xyz', 'version': '12.2'}) 

or set vars in dict:

print ('my job name', {'branch_name': branch , 'version': version}) # ('my job name', {'branch_name': 'xyz', 'version': '12.2'}) 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -