[英]How can I disable use of Python programs on certain operating systems?
I wish to disable the ability to run my program on certain Windows operating systems to prevent certain issues I can't replicate in newer versions. 我希望禁用在某些Windows操作系统上运行程序的功能,以防止某些无法在较新版本中复制的问题。 I would like to prevent running it on Windows XP, Vista, and eventually, 7.
我想防止在Windows XP,Vista以及最终版本7上运行它。
How can I achieve this? 我该如何实现? For a little while I used an if statement with _platform but that did not work well or efficiently.
有一阵子,我使用了带有_platform的if语句,但是效果不佳或效率很高。
You can use sys.getwindowsversion
: 您可以使用
sys.getwindowsversion
:
import sys
ver = sys.getwindowsversion()
if ver.major == 6 and ver.minor == 1:
print('Windows 7')
elif ver.major == 6 and ver.minor == 0:
print('Windows Vista')
elif ver.major == 5 and ver.minor == 0:
print('Windows XP')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.