asp
asp

Reputation: 855

how to substitute variable value in url

I am trying to include variable value into url

ip= sys.argv[1]
    
https://management.azure.com/Subscriptions/xxxxxx/resourceGroups/xxxxxx/providers/Microsoft.RecoveryServices/vaults/{ip}/backupProtectedItems?api-version=2019-05-13&

but when i print url i am getting like below as it is ip is not substituting

https://management.azure.com/Subscriptions/xxxxxx/resourceGroups/xxxxxx/providers/Microsoft.RecoveryServices/vaults/{ip}/backupProtectedItems?api-version=2019-05-13&

can some one please suggest

Upvotes: 0

Views: 97

Answers (1)

Adam.Er8
Adam.Er8

Reputation: 13413

assuming you're using Python >= 3.6 and trying to use f-strings, you need to prefix your string literal with f, like this:

ip="11.22.33.44"

s = f"url/with/{ip}/and/stuff" #notice the f before the opening quote
print(s)

Output:

url/with/11.22.33.44/and/stuff

Upvotes: 1

Related Questions