So I've been using Python for quite a long time and I've always used the following structure to print the variable:
dt = 5.5 print("dt = " + str(dt)) but I know there's a more elegant version of this command which is:
dt = 5.5 print("dt = %f" % dt) But I constantly get the error:
Traceback (most recent call last): File "C:\Users\Komputer\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2980, in run_code self.showtraceback(running_compiled_code=True) File "C:\Users\Komputer\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 1849, in showtraceback self.showsyntaxerror(filename, running_compiled_code) File "C:\Users\Komputer\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 1911, in showsyntaxerror stb = self.SyntaxTB.structured_traceback(etype, value, elist) File "C:\Users\Komputer\Anaconda3\lib\site-packages\IPython\core\ultratb.py", line 1408, in structured_traceback newtext = linecache.getline(value.filename, value.lineno) File "C:\Users\Komputer\Anaconda3\lib\linecache.py", line 16, in getline lines = getlines(filename, module_globals) File "C:\Users\Komputer\Anaconda3\lib\linecache.py", line 47, in getlines return updatecache(filename, module_globals) File "C:\Users\Komputer\Anaconda3\lib\linecache.py", line 137, in updatecache lines = fp.readlines() File "C:\Users\Komputer\Anaconda3\lib\codecs.py", line 321, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf3 in position 83: invalid continuation byte What can be wrong? I suppose this is something with text codecs but I don't know where to change it. The same error shows up when printing other type of variables. I've looked up on several questions where this error appears but none of it was about printing.
I am using Spyder 3.2.8 (Python 3.6)