It depends on how much information you need.
os.name will give you only a high-level view of the environment you are in (for example, POSIX vs. Windows NT) - even the name of the operating system. The documentation says:
See also sys.platform has finer granularity. os.uname() provides system version information. The platform module provides detailed system identity checks.
sys.platform gives you a little more information and can actually tell you if you are using Linux or FreeBSD, for example.
The platform module will provide you with the most complete information, up to the version of the operating system in which you work, and information about the processor.
So, you must indicate what exactly you are trying to execute, and then it will probably become clear which method is most suitable.
source share