Python os.getpid() - 获取当前进程的进程ID

星星跌入梦境

Python os.getpid()

Python中的os.getpid()方法用于获取当前进程的进程ID

语法:os.getpid()

参数:不需要

返回类型:该方法返回一个整数值,表示当前进程的进程ID。这个方法的返回类型是’ int ‘类。

示例1

使用os.getpid()方法

# Python program to explain os.getpid() method 
    
# importing os module 
import os
  
# Get the process ID of
# the current process
pid = os.getpid()
  
  
# Print the process ID of
# the current process
print(pid) 

输出:

2699

版权声明:本页面内容旨在传播知识,为用户自行发布,若有侵权等问题请及时与本网联系,我们将第一时间处理。E-mail:284563525@qq.com

目录[+]

取消
微信二维码
微信二维码
支付宝二维码