saving . . . saved primes=loadtxr() cmd not working has been deleted. primes=loadtxr() cmd not working has been hidden .
primes=loadtxr() cmd not working
I am using Python in windows10. Used !type for loading file. But unable to perform loadtxt() cmd;to store the list in variable primes.
 File "<ipython-input-4-fb9b7fac2a2b>", line 1
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

Python-3.4.3 Loading-Data-From-Files 02-03 min 0-10 sec 08-01-21, 8:54 p.m.


<a href="" target="" title=""></a>
15-03-21, 12:50 p.m. iakashchavan

The error message you're seeing indicates that Python encountered a string with a Unicode escape sequence that is truncated, meaning it doesn't have the required number of hexadecimal digits. The position 2-3 in the error message refers to the location in the string where the error occurred.

You can solve this error "<a href="" target="" title="">codec can't decode bytes</a>" by using a raw string by prefixing your string with the letter "r". Raw strings don't interpret backslashes as escape characters.
path = r"C:\Users\User\Documents\file.txt"

Double the backslashes in your string
path = "C:\\Users\\User\\Documents\\file.txt"

Use forward slashes instead of backslashes
path = "C:/Users/User/Documents/file.txt"

27-02-23, 10:45 a.m. linehammer

Log-in to answer to this question.