-1

I need to add a number into a site which is then processes in python:

text = "4122822"
get = 'http://example.com/api/jobs/text/'

I want text to go where I wrote it inside the link. Is there a way to do it? Thanks

Kitama
  • 21
  • 1
  • 4
  • Do you mean simple string interpolation ? It can be done by `get = "http://example.com/api/jobs/" + text + "/"` – Rajarishi Devarajan Apr 17 '20 at 09:57
  • 1
    Does this answer your question? [Making a string out of a string and an integer in Python](https://stackoverflow.com/questions/2823211/making-a-string-out-of-a-string-and-an-integer-in-python). See also: [How can I concatenate str and int objects?](https://stackoverflow.com/questions/25675943/how-can-i-concatenate-str-and-int-objects). Also, since `text` is already a string: [Which is the preferred way to concatenate a string in Python?](https://stackoverflow.com/questions/12169839/which-is-the-preferred-way-to-concatenate-a-string-in-python) – dspencer Apr 17 '20 at 10:03

2 Answers2

0

You just need to append it like below :

text = "4122822"
get = 'http://example.com/api/jobs/'+text +'/'
Abhishek Kulkarni
  • 1,747
  • 1
  • 6
  • 8
0

Python3:

get = f'http://example.com/api/jobs/{text}/'

Python2:

get = 'http://example.com/api/jobs/{}/'.format(text)
Pavel Francírek
  • 188
  • 2
  • 10