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
Post a Comment