regex - Python: Unicode string and Escape sequences -
regex - Python: Unicode string and Escape sequences -
lets have text file containing line double slashes. example,
... 3\\/4 ...
when open file in python , seek process lines, next issue:
f = open("example.txt") line in f: print(line) #prints "3\/4" instead of "3\\/4"!!
so guess when unicode converted python string, double slashes escaped single slash... how prevent this??
i know when i'm creating string, can this:
x = r"3\\/4"
but i'm not sure how can string variable ("line" in case)?
thanks
you utilize python's raw string notation adding r
..
>>> uni = ur"a\\/b" >>> print(uni) a\\/b
python regex string unicode
Comments
Post a Comment