Python 不使用手工加 r,可以把字符串转换为原始字符串吗? s = '[{"id":"","name":"","amount":"","ver":""}]' 不把这个字符串变为原始字符串的话,Python 默认对这个\转义就变成\这样了,再把这样的字符串发送出去,别的平台接受到的就变成'[{\"id\":\"\",\"name\":\"\",\"amount\":\"\",\"ver\":\"\"}]'这样了,有或者有什么办法让它原样发送出去吗
1
Wincer 2018-09-21 16:05:27 +08:00
你把 s = '[{"id":"","name":"","amount":"","ver":""}]' 转成 JSON obj 再发出去不就可以了,为啥要发字符串出去
|
2
Delav OP @Wincer 上面说错了,就是字符串是'[{\"id\":\"\",\"name\":\"\",\"amount\":\"\",\"ver\":\"\"}]'这样的,我又想把这个字符串原样发送出去(还是带有\的),怎么办?
|
3
Wincer 2018-09-21 17:41:47 +08:00
@Delav
``` >>> s = repr('[{\"id\":\"\",\"name\":\"\",\"amount\":\"\",\"ver\":\"\"}]') >>> s '\'[{"id":"","name":"","amount":"","ver":""}]\'' ``` |