Why does this string not work with ast.literal_eval

左心房为你撑大大i 提交于 2019-11-30 22:34:11

From the ast.literal_eval docs:

The string or node provided may only consist of the following Python literal structures: strings, numbers, tuples, lists, dicts, booleans, and None.

Concatenation using + isn't included within that: it's not a literal expression, it's a call to str.__add__. It's the same reason 1+1 or "hello".upper() wouldn't work.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!