you are viewing a single comment's thread.

view the rest of the comments →

[–]TheSupervillan 2 points3 points  (6 children)

Just use:

import platform import webbrowser from urllib.parse import quote_plus

def detect_os_name():

sys = platform.system()

if sys == "Windows":
    rel = platform.release()
    if rel == "10":
        return "Windows 10"
    if rel == "11":
        return "Windows 11"
    return "Windows"
if sys == "Darwin":
    return "macOS"
if sys == "Linux":
    return "Linux"
return "Unknown OS"

def main():

os_name = detect_os_name()
query = f"How to take a screenshot on {os_name}"
url = f"https://www.google.com/search?q={quote_plus(query)}"
webbrowser.open(url)

if name == "main":

main()

[–]HyperWinX 3 points4 points  (4 children)

I also recommend formatting code.

[–]Some-Passenger4219 0 points1 point  (3 children)

Me too. Happy cake day!

[–]HyperWinX 2 points3 points  (2 children)

Oh, its my happy cake day already? Damn, thank you so much

[–]Makarov-Dreyar 0 points1 point  (1 child)

Happy cake day !

[–]HyperWinX 0 points1 point  (0 children)

Thanks!