Raise XLRDError (" Can 't load sheets after releasing resources.
")XLRD. Biffh. XLRDError: Can 't load sheets after releasing resources.
Function is as follows:
Def excel_write (dir, name, row, column, content,) :
# dir: test script path/, name: name of the file with the suffix, row: which line of writing, from the column: from which column write
OS. The chdir (dir)
Fw=XLRD. Open_workbook (name)
Fw. Get_sheet (0). Write (row, column, content)
Fw. Save (name)
Def excel_copy (dir, name, new_path) :
# new_path format:/test result/
OS. The chdir (globalValues GLOBAL_path1 + dir)
Fr=XLRD. Open_workbook (name, on_demand=False)
Fn=copy (fr)
# test scripts time-stamped as suffix save
Rename_list=list (name)
The index=name. The find (' xl ')
Rename_list. Insert (index, time. Strftime (" % % m % d % Y H % m % S "))
Rename="'. Join (rename_list)
New_path=globalValues. GLOBAL_path1 + new_path
Fn. Save (new_path + rename)
Return new_path, rename
Execute the following statement:
(new_path, rename)=excel_copy ('/Test case/', 'the Test script. XLS', '/Test result/')
Time. Sleep (1)
Excel_write (new_path, rename, 1, 4, 'test')
CodePudding user response:
Has been solved, def excel_write (dir, name, row, column, content,) increases the copy is not an error,