-3

I came across this interesting question my friend asked me. He told that he found a way to know which os we are on without importing the os module. Can any of you help me with the same?

ForceBru
  • 43,482
  • 10
  • 63
  • 98

2 Answers2

1
import platform
print(platform.system())
print(platform.release())
print(platform.version())
liagason
  • 93
  • 2
  • 10
1

perhaps this could work:

if r"\" in __file__: print("Windows") 
else: print("Unix variant")
Alain T.
  • 40,517
  • 4
  • 31
  • 51