Is there an easy way to convert a string containing a string literal into the string it represents?

前端 未结 2 831
隐瞒了意图╮
隐瞒了意图╮ 2021-01-23 02:01

I\'m trying to (slightly) improve a script that does a quick-and-hacky parse of some config files.

Upon recognising \"an item\" read from the file, I need to try to conv

2条回答
  •  无人及你
    2021-01-23 02:48

    ast.literal_eval() handles all simple Python literals, and most compound literals.

提交回复
热议问题