Python 3.x 从MongoDB字符串中以字符串形式执行Python代码无效
我在Python中的代码有问题,我需要从MongoDB的字符串提取执行Python代码,但我有一个语法错误:Python 3.x 从MongoDB字符串中以字符串形式执行Python代码无效,python-3.x,string,mongodb,exec,Python 3.x,String,Mongodb,Exec,我在Python中的代码有问题,我需要从MongoDB的字符串提取执行Python代码,但我有一个语法错误: def test():\n\treturn "hello"\nresult = test()\n File "<string>", line 1 SyntaxError: unexpected character after line continuation character 字符串变量Python内容组件['Python']
def test():\n\treturn "hello"\nresult = test()\n
File "<string>", line 1
SyntaxError: unexpected character after line continuation character
字符串变量Python内容组件['Python']:
def test():\n\treturn "ici"\nresult = test()\n
我尝试过许多解决办法,但没有找到一个
def test():\n\treturn "ici"\nresult = test()\n