Skip to content Skip to sidebar Skip to footer

Typeerror: Expected Str, Bytes Or Os.pathlike Object, Not Tuple

So I am trying to create a form of encryption program with a GUI. Here is the code: import sys from PyQt4 import QtGui, QtCore import os from Crypto.Hash import SHA256 from Crypto

Solution 1:

You define outputfile as follows:

outputFile = "(Krypteret)", filename

which is a tuple, hence the error. It's not clear what you mean here; perhaps you wanted to prepend the word "(Krypteret)" to the existing filename? In which case you should do

outputFile = "(Krypteret)" + filename

(In future, please cut your code down to the minimum. The error is entirely within the encrypt method, you should have just posted that method.)

Solution 2:

Or this:

outputFile = "(Krypteret)%s"%filename

Or this:

outputFile = "(Krypteret){}".format(filename)

This could not work depends on your python version:

outputFile = f"(Krypteret){filename}"

Your code doesn't work because outputFile = "(Krypteret)", filename returns an tuple.

Post a Comment for "Typeerror: Expected Str, Bytes Or Os.pathlike Object, Not Tuple"