Найти - Пользователи
Полная версия: sys.platform linux2
Начало » Python для новичков » sys.platform linux2
1
74LS00
Надо было определить ось. Нашёл такую страницу.
Под виндой получил win32 , хоть она и не 32, но под линуксом работать не захотело, как оказалось это linux2 .
Что это за зверь такой linux2 и почему он не просто linux и какие ещё варианты есть.
Вроде как есть linux3, это тип питона или ядра?

Насколько правильный такой вариант
     def infoprogram(self):
        if sys.platform == 'win32':
            subprocess.Popen('mmc devmgmt.msc')
        elif sys.platform == 'linux' or 'linux2':
            subprocess.Popen(shlex.split('/usr/bin/mate-terminal --title port -e '+self.get_pkg_path('..//..//programmer//linux//port.sh')))
        else:
            return
Под линём почемуто только через костыльный скрипт окно работает, напрямую сразу закрывается, но не суть
ZerG
 from sys import platform
if platform == "linux" or platform == "linux2":
    # linux
elif platform == "darwin":
    # OS X
elif platform == "win32":
    # Windows...

Описание

Changed in version 2.7.3: Since lots of code check for sys.platform == ‘linux2’, and there is no essential change between Linux 2.x and 3.x, sys.platform is always set to ‘linux2’, even on Linux 3.x. In Python 3.3 and later, the value will always be set to ‘linux’, so it is recommended to always use the startswith idiom presented above.

For other systems, the values are:

System platform value
Linux (2.x and 3.x) ‘linux2’
Windows ‘win32’
Windows/Cygwin ‘cygwin’
Mac OS X ‘darwin’
OS/2 ‘os2’
OS/2 EMX ‘os2emx’
RiscOS ‘riscos’
AtheOS ‘atheos’

Так что нам рекомендуют что-то типа токого

 if sys.platform.lower().startswith('win'):
    ололо
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB