python 用于在扫描包含 url 的条形码时自动打开 Web 浏览器
python for automatically open a web browser when scanning a barcode containing url
我遵循了 Janekmuric Industrial Handheld QRCode Scanner Open URL in Browser. This python script there really help me but I have 2 questions: is there any way that it can read example.com/something-something instead of it has to be http://example.com/something-something 在这个 post 中的回答。此外,此处的脚本切断了“.com”后面的任何内容。我的 url 后面有零件。有没有人可以帮我修改这个 python 代码,这样它就不会在 ".com"
之后切断任何东西
非常感谢!
因此,我不相信有不需要 'http://' 的库,因为获取任何网站都需要 HTTP。你可以这样做:
import webbrowser
url = "http://" + str(url) #where url is the url gotten by the scanner
webbrowser.open(url)
为了更接近您的代码,它说 webbrowser.open(url)
只需将 "http://
放在 url 字符串的前面。
至于你的第二个问题,我很困惑。你一开始说,"the script here cut off anything behind ".com""。但是在最后一句,你说反了,"modify this python code so it does not cut off anything after ".com":.那么是截掉before还是after?
我遵循了 Janekmuric Industrial Handheld QRCode Scanner Open URL in Browser. This python script there really help me but I have 2 questions: is there any way that it can read example.com/something-something instead of it has to be http://example.com/something-something 在这个 post 中的回答。此外,此处的脚本切断了“.com”后面的任何内容。我的 url 后面有零件。有没有人可以帮我修改这个 python 代码,这样它就不会在 ".com"
之后切断任何东西非常感谢!
因此,我不相信有不需要 'http://' 的库,因为获取任何网站都需要 HTTP。你可以这样做:
import webbrowser
url = "http://" + str(url) #where url is the url gotten by the scanner
webbrowser.open(url)
为了更接近您的代码,它说 webbrowser.open(url)
只需将 "http://
放在 url 字符串的前面。
至于你的第二个问题,我很困惑。你一开始说,"the script here cut off anything behind ".com""。但是在最后一句,你说反了,"modify this python code so it does not cut off anything after ".com":.那么是截掉before还是after?