请给出python实现多进程的示例代码
时间: 2023-02-02 21:42:17 浏览: 125
Python实现的多进程拷贝文件并显示百分比功能示例
Python 中可以使用 `multiprocessing` 模块实现多进程。以下是一个简单的示例代码:
```python
import multiprocessing
def worker(number):
print("Worker %d is running" % number)
if __name__ == '__main__':
for i in range(5):
process = multiprocessing.Process(target=worker, args=(i,))
process.start()
```
运行结果:
```
Worker 0 is running
Worker 2 is running
Worker 1 is running
Worker 4 is running
Worker 3 is running
```
阅读全文