试图解析 print 语句中的变量。
client = fabric.operations.prompt("Enter client's email address:")
cmd = 'mysql -u %s -p%s -e "UPDATE users SET email = ' %(env.user, dbpasswd) + '"%client"' + ' WHERE id = 1" %s' %account
print cmd
结果:
mysql -u root -password -e "UPDATE users SET email = %client WHERE id = 1" demo
期望的结果:
mysql -u root -password -e "UPDATE users SET email = 'abc@xyz.com' WHERE id = 1" demo