python - How do I format a string within a function call? -


i want pass string variable string, in turn gets passwd onto function. had written code below:

not working

env = 'd' myfunction("checking processes a%s/b%s",'')% (env,env) 

error

myfunction("checking processes a%s/b%s",'')% (env,env) typeerror: unsupported operand type(s) %: 'nonetype' , 'tuple' 

since code failed re-wrote below:

working

env = 'd' str = "checking processes a%s/b%s" %(env,env) myfunction(str,'') 

can suggest alternative shorter approaches ?ideally in lines of first attemp mean less loc.

myfunction("checking processes a%s/b%s" % (env,env),'') 

Comments

Popular posts from this blog

javascript - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -