How do you put the variable in the line?



  • How do you add a variable to the line? Modified ser needs to be added to the XXX location, the idea that when an ipi get the request is sent to ip what we have indicated.

    import requests
    

    data = {'user': '' ,'text' : '' }
    ser = str(input())
    response = requests.get('http://XXX/getmessages', params=data)
    print(response.status_code)
    print(response.text)



  • There's a cake in the modern world. f-строки:

    ser = input() # input и так выдаёт строку, преобразовывать не нужно
    response = requests.get(f'http://{ser}/getmessages', params=data)
    

    In older versions, too, there are options to connect the lines through. + or use old formatting options.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2