Jan-27-2023, 05:36 AM
I am trying to find a string in a text file and get an error on the first find statement.
(unicode error) 'unicodeescape' codec can't decode bytes in position 0-1: truncated \xXX escape
How do I correct this?
"irec" contains:
\v 1 \x - \xo 1:1 \xt Ps 90:2; Jes 40:21-22; Joh 1:1-3; Hand 17:24; Kol 1:16-17; Heb 1:10; 11:3\x*In die begin het God die hemel en die aarde geskep.
xrefstart=irec.find("\x - \xo ") if xrefstart > 0: #find the \xt which is the start of the xref xstar=irec.find("x*") xref = "<RX>"+irec[chr+10:xstar]+"<Rx>" # replace everything up to the "x* " with xref regexp = "\x - \xo .*?\x* " re.sub(regexp, xref, irec)The error reads:
(unicode error) 'unicodeescape' codec can't decode bytes in position 0-1: truncated \xXX escape
How do I correct this?
"irec" contains:
\v 1 \x - \xo 1:1 \xt Ps 90:2; Jes 40:21-22; Joh 1:1-3; Hand 17:24; Kol 1:16-17; Heb 1:10; 11:3\x*In die begin het God die hemel en die aarde geskep.