>>> ascii('泷夜叉姬')
"'\\u6cf7\\u591c\\u53c9\\u59ec'"
如何将"'\\u6cf7\\u591c\\u53c9\\u59ec'"
还原回去?
1
matrixji 2021-09-18 22:36:49 +08:00
>>> eval(ascii('泷夜叉姬'))
'泷夜叉姬' >>> |
2
getcharch 2021-09-18 22:41:59 +08:00
ascii('泷夜叉姬').encode('ascii').decode('unicode_escape')
|
3
iBugOne 2021-09-18 23:19:14 +08:00 via Android 1
>>> import ast
>>> ast.literal_eval(ascii('泷夜叉姬')) '泷夜叉姬' >>> |
4
yuguorui96 2021-09-19 17:03:15 +08:00
|
5
frostming 2021-09-22 09:50:09 +08:00
#2 是「正」解,literal_eval 是次优解,eval 是歪解
|