Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to add parameters to url in python

Hello i have this code in javascript i have made where i give parameters in the url this is the javascript code:

let user_id = '1234567890';

var chat_id = ['@test1','@test2'];

url: `https://api.telegram.org/bot1234567890/banChatMember?chat_id=${chat_id[i]}&user_id=${user_id}`

This code works great the paramets pass, my question is if it is possible to do something like this in python i saw some passing parameters but i couldnt understand it thats why im asking here.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use f-strings for this. (Note that regular string concatenation with + always works in these cases, as well.)

user_id = '1234567890'
chat_id = ['@test1','@test2']
i = 0
url = f'https://api.telegram.org/bot1234567890/banChatMember?chat_id={chat_id[i]}&user_id={user_id}'
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading