OSError: [Errno 22] Invalid argument. The error occurs when saving a file with special characters. On windows

Viewed 24
def image_validator(url_column_number, filename, sheet_name, hatch, status):
wb = load_workbook(filename)
sheet = wb[sheet_name]
try:
    v_image = Image.open(f'{FILES_PATH}{str(hatch)}.png')
    print(f'{FILES_PATH}{str(hatch)}.png')
    v_image.verify()
    print('Valid image')
except OSError as e:
    print(e)
    url = sheet[url_column_number].value
    if status == 444:
        sheet[url_column_number] = url + "(Сервер блокирует скачивание)"
    else:
        sheet[url_column_number] = url + "(Не валидная ccылка)"
    wb.save(filename)
    wb.close()
    try:
        os.remove(f'{FILES_PATH}{str(hatch)}.png')
    except OSError as e:
        pass

OSError: [Errno 22] Invalid argument. The error occurs when saving a file with special characters. On Linux everything works fine, but on Windows it gives the same error. Please, help

0 Answers
Related