try:
    zf.testzip()
except RuntimeError as e:
    if 'encrypted' in str(e):
        print('Golly, this zip has encrypted files! Try again with a password!')
else:
    pass
How to check if a zip file is encrypted using python's standard library zipfile?