【发布时间】:2023-03-21 10:05:01
【问题描述】:
有一些模块需要在被调用时才被调用以执行某些过程。
喜欢:-
import os
from mpi4py import MPI
x= ["10","02","03,"04"]
def manta(int):
os.systems("time manta ripper -l "+x[int]"")
def rip(int):
os.systems("time rip -b -mb "+x[int]+"")
def save(int):
os.systems("time merger -h -i "+x[int]" -l -s ")
if rank < 4:
return(rank)
对于每个 def 函数,它必须使用从 mpi4py 获取的排名来运行。
【问题讨论】:
-
请发布可运行代码。此外,使用 Python 内置类型作为变量名是一个非常糟糕的主意。我猜你想根据'rank'的值执行不同的功能。如果是这样,那么使用与相关函数相等的值键入排名的字典就是要走的路