Форум сайта python.su
Надо было определить ось. Нашёл такую страницу.
Под виндой получил 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
Отредактировано 74LS00 (Янв. 23, 2017 04:29:00)
Офлайн
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'): ололо
Офлайн