-1


        def openany():
            url = self.textentry.get()
            print(format('https://%s'% url))
            wb.get(c).open(('https://%s'% url))


I want it to format my entry to include Https:// before the entry. Instead it will print this way but not open it that way.

  • 1
    Have you considered the fact that you computed `fullurl` but you're not actually using it anywhere? – Bryan Oakley Oct 19 '21 at 18:56
  • Try using simply `fullurl = 'https://%s' % url`. There is no need to call `format()` there. Also, you need to use `wb.open(fullurl)` (or `wb.get(c).open(fullurl)`). – Sylvester Kruin Oct 19 '21 at 18:56
  • Even better, us an f-string: `f"https://{url}"` – Bryan Oakley Oct 19 '21 at 19:05
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 19 '21 at 19:14
  • @BryanOakley i updated it but this does not work. – ThePythonBegginer Oct 19 '21 at 20:05
  • If `wb` is the alias of `webbrowser` module and `url` is a valid URL, for example `google.com`, then `wb.open(f'https://{url}')` should open `Google` web site in the default browser. – acw1668 Oct 20 '21 at 01:03

1 Answers1

1
def openany():
    url = self.textentry.get()
    print(f'https://{url}')
    wb.open(f'https://{url}')

As someone in the comment already said, use a f-string, there is no need for (format) and stuff like that.

  • still, doesn't work. It prints it right, but doesn't search the web with the https:// before the entry. – ThePythonBegginer Oct 19 '21 at 21:04
  • Then what happens after you run that function?, because the code i wrote up there should work, that string called "url" gets the textentry first, then it prints the url the user entered in the entry, then the wb.open() opens the link in your webbrowser, with https:// at the beginning. Also, which website did you tried to open, the website might have http:// instead of https:// at the beginning. But it might be because of your browser, try using google chrome, in case you are not using it already. –  Oct 20 '21 at 08:13