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

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

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

ios - I get the error Property '...' not found on object of type '...' -