我在“Sample.py”的python“Sample.py”和“GenericFunctions.py”中编写了两个模块,我正在调用一个函数
存在于“GenericFunctions.py”中,但我无法将该函数调用为“AttributeError:'module'对象没有属性'fn_ElseLog'”
Sample.py 中的代码:
import GenericFunctions
def sampleee():
g_TCaseID="SD1233"
g_TCDescription="Login"
g_TestData="hi"
g_Result="Fail"
g_Remarks="testing"
g_TargetEnvironment="S1"
g_TargetSystem="Legacy"
g_TargetRegion="EU"
x = GenericFunctions.fn_ElseLog(g_TCaseID, g_TCDescription, g_TestData, g_Result, g_Remarks)
sampleee()
GenericFunctions.py 中的代码:
def fn_ElseLog(g_TCaseID, g_TCDescription, g_TestData, g_Result, g_Remarks):
print "entered in ElseLog Function"
Output= fn_Output(g_TCaseID, g_TCDescription, g_TestData, g_Result , g_Remarks)
print ("Testcase"+"'"+g_TCDescription+"'"+"execution completed"+"'"+g_TargetEnvironment+"-"+g_TargetRegion)
def fn_Output(p_TCaseID, p_TCDescription, p_TestData, p_Result , p_Remarks):
OutputSheet=""
OutputSheet="\Test"+"_"+g_TargetEnvironment+"_"+g_TargetSystem+"_"+g_TargetRegion+".xlsx"
OutputPath=r"C:\Users\u304080\Desktop\PlayAround\Shakedowns\OutputResultFiles"
#objExcel1 = win32.gencache.EnsureDispatch('Excel.Application')
Outputfile=os.path.exists(OutputPath+OutputSheet)
if Outputfile==True :
print('Output file is present')
else:
print('Output file is not present')
return
objExceloutput = win32.gencache.EnsureDispatch('Excel.Application')
#excel.DisplayAlerts = False
objoutputworkbook = objExceloutput.Workbooks.Open(OutputPath+OutputSheet)
objSheetOutput = objoutputworkbook.Sheets(1)
OutputRowCount =objSheetOutput.UsedRange.Rows.Count
print "OutputRowcount" , OutputRowCount
objSheetOutput.Cells(OutputRowCount+1,1).Value=p_TCaseID
objSheetOutput.Cells(OutputRowCount+1,2).Value=p_TCDescription
objSheetOutput.Cells(OutputRowCount+1,3).Value=p_TestData
objSheetOutput.Cells(OutputRowCount+1,4).Value=p_Result
objSheetOutput.Cells(OutputRowCount+1,4).Font.Bold = True
if p_Result=="Pass":
objSheetOutput.Cells(OutputRowCount+1,1).Font.ColorIndex = 10
else:
objSheetOutput.Cells(OutputRowCount+1,1).Font.ColorIndex = 3
objoutputworkbook.SaveAs(OutputPath)
objSheetOutput=None
objoutputworkbook=None
objExceloutput.Quit()
objExceloutput=None
你们能告诉我一个解决方案吗?