[英]How to pass instance variable as argument which can persist in function for multiple calls?
I'm using Androguard to analyze some malware files. 我正在使用Androguard分析一些恶意软件文件。 Currently I'm trying to get androsim.py to analyze a file with its entire directory.
目前,我正在尝试获取androsim.py来分析具有整个目录的文件。 The objective is to iterate over all folders where in each folder you compare files with the other files in your folder.
目的是遍历所有文件夹,在每个文件夹中,您将文件与文件夹中的其他文件进行比较。
I'm not able to get androsim running in another script, one of the arguments to the main function is an instance variable, whose value is transient and the code breaks? 我无法在另一个脚本中运行androsim,主函数的参数之一是实例变量,其值是瞬态的并且代码中断了?
import androsim
import sys, os
from optparse import OptionParser
from androsim import options
parser = OptionParser()
for option in options :
param = option['name']
del option['name']
parser.add_option(*param, **option)
options, arguments = parser.parse_args()
sys.argv[:] = arguments
print options,arguments
androsim.main(options, arguments)
It's not entirely clear what you're after here, but if the instance object you have is mutating between passing it into the function and using it, then make a copy of it and pass the copy in instead: 目前尚不清楚您要执行的操作,但是如果您拥有的实例对象在将其传递给函数和使用它之间发生了变异,请对其进行复制并传递给副本:
from copy import deepcopy
intransient = deepcopy(options)
androsim.main(intransient, arguments)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.