How to convert a raw string r'\xdd' to '\xdd' more gracefully?

Jach Feng jfong at ms4.hinet.net
Fri Dec 9 21:12:41 EST 2022


moi 在 2022年12月9日 星期五晚上11:41:20 [UTC+8] 的信中寫道:
> PS C:\humour> py38 sysargwithliteral.py a\x0ab\x09c\x0a\x80uro\x0ax\x08z cp1252 
> a 
> b c 
> €uro 
> z 
> 
> PS C:\humour> $a = py38 sysargwithliteral.py a\x0ab\x09c\x0a\x80uro\x0ax\x08z cp1252 
> 
> PS C:\humour> licp($a) 
> a U+0061 
> b U+0062 
> U+0009 
> c U+0063 
> € U+20AC 
> u U+0075 
> r U+0072 
> o U+006F 
> x U+0078 
> U+0008 
> z U+007A 
> 
> PS C:\humour> 
> 
> PS C:\humour> py38 sysargwithliteral.py a\u000ab\u0009c\u000a\u20acuro\u000ax\u0008z\u000aend\U0001f60a unicode 
> a 
> b c 
> €uro 
> z 
> end😊 
> 
> PS C:\humour> 
> 
> PS C:\humour> py38 sysargwithliteral.py a\x0ab\x09c\x0a\x80uro\x0ax\x08z cp1252 | py38 -c "import sys; s = sys.stdin.read(); print(s.rstrip())" 
> a 
> b c 
> €uro 
> z 
> 
> PS C:\humour> 
> Note: In a terminal "\t" is correct.
Where is the sysargwithliteral.py?


More information about the Python-list mailing list