Usa sys.platform
. Puoi trovare maggiori informazioni qui http://docs.python.org/library/platform.html
vedi qui:https://stackoverflow.com/a/58689984/3752715
import platform
plt = platform.system()
if plt == "Windows": print("Your system is Windows")
elif plt == "Linux": print("Your system is Linux")
elif plt == "Darwin": print("Your system is MacOS")
else: print("Unidentified system")
puoi vedere il mio repository github https://github.com/sk3pp3r/PyOS e usare lo script pyos.py
Di solito uso solo questo:
import os
if os.name == 'nt':
pass # Windows
else:
pass # other (unix)
modifica:
Si spera in risposta ai tuoi commenti:
from time import strftime
import os
if os.name == 'nt': # Windows
basePath = 'C:\\working\\'
else:
basePath = '/working/'
Fn = '%sSetup%s.csv' % ( basePath, strftime( '%y%m%d' ) )