Reputation: 29
I am currently sending an api request and am using the following params:
params = (
('adminDeviceSpaceId', '1'),
('fields', 'special.field'),
('query', 'user.email_address="[email protected]"'),
)
requests.get works fine, i need to replace the email with a variable (passed in from another program). When i replace the email= with
EMAIL_VARIABLE = '[email protected]'
('query', 'user.email_address="(EMAIL_VARIABLE)"'),
it does not work, tried every permutation of removing and changing quotes. Has to be something simple.
It is on RHEL7 so it is python 2.7.5.
Upvotes: 0
Views: 169
Reputation: 1781
For anyone using Python 3
https://realpython.com/python-f-strings/
f"user.email_address={EMAIL_VARIABLE}"
Usage :
>>> print(f'user.email_address={EMAIL_VARIABLE}')
[email protected]
Python 2.7
print 'user.email_address={}'.format(EMAIL_VARIABLE))
or
print 'user.email_address={0}'.format(EMAIL_VARIABLE))
Upvotes: 1
Reputation: 6043
In Python 2.7 you can use:
'user.email_address="{}"'.format(EMAIL_VARIABLE)
Upvotes: 4