如何在python
中使用操作系统预处理器宏来实现特定于操作系统的代码。
例如,在C/C++中,我们在下面使用。
#ifdef __linux__
//linux code goes here
#elif _WIN32
//windows code goes here
#else
//Other OS code goes here
#endif
python也存在类似的东西。
发布于 2020-11-30 07:19:31
导入sys模块
import sys
if sys.platform == 'win32':
#windows code
elif sys.platform == 'linux':
#linux code
https://stackoverflow.com/questions/65069337
复制相似问题