更新时间:2023-12-05 09:48:40
Mark 的回答是要走的路,毕竟这就是/proc 文件系统存在的原因.对于一些更多的复制/粘贴:
Mark's answer is the way to go, after all, that's why the /proc file system is there. For something a little more copy/pasteable:
>>> import os.path
>>> os.path.exists("/proc/0")
False
>>> os.path.exists("/proc/12")
True