Pro Q
Pro Q

Reputation: 5038

How to tell if I'm on a Mac or iOS

I'd like to be able to do stuff like

from os import system
system(f'say "hello world"')

But this only works on Mac, not iOS.

I know I can detect a Mac by using platform.system(), but that doesn't tell me Mac vs iOS.

I've also noticed that platform().platform() has the substring "iPad" in it when I'm running on an iPad, but I'm not sure if that's documented/can be relied on, or if on an iPhone it will do something similar.

Upvotes: 0

Views: 52

Answers (1)

Saptarshi
Saptarshi

Reputation: 148

You may use the following code.

from sys import platform
print(platform)

enter image description here

Upvotes: 1

Related Questions