Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

309
Views
¿Cuál es la forma pythonic de construir URL completas para enlaces?

Estoy buscando una forma de crear direcciones URL en python3 sin tener que hacer una concatenación de cadenas. entiendo que puedo

 import requests url_endpoint = 'https://www.duckduckgo.com' mydict = {'q': 'whee! Stanford!!!', 'something': 'else'} resp = requests.get(url_endpoint, params=mydict) print(resp.url) # THIS IS EXACTLY WHAT I WANT

o

 from requests import Request, Session s = Session() req = Request('GET', url, params={'q': 'blah'}) print(req.url) # I didn't get this to work, but from the docs # it should build the url without making the call

o

 url = baseurl + "?" + urllib.urlencode(params)

Me gusta que la biblioteca de solicitudes decida abandonar de forma inteligente ? si no es necesario, pero ese código en realidad hace una solicitud GET completa, en lugar de simplemente crear una URL de texto completo (que planeo volcar en una etiqueta html). Estoy usando django, pero no vi nada que me ayudara con eso en la biblioteca central.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Django viene con QueryDict s que básicamente hace todo lo que quieres.

 def make_url(url, args=None): query = QueryDict(mutable=True) query.update(args or {}) return '{}{}{}'.format(url, '?' if query else '', query.urlencode())

Admite múltiples valores por argumento, como puede encontrar en una URL: example.com/foo?a=1&a=2&a=3 .

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!