一个FileStorage对象我有这个字符串:我怎样才能从字符串
str = "FieldStorage('myfile', 'file.exe', 'hello\\n')"
所以我想知道是否有办法从字符串
一个FileStorage对象我有这个字符串:我怎样才能从字符串
str = "FieldStorage('myfile', 'file.exe', 'hello\\n')"
所以我想知道是否有办法从字符串
你可以得到FileStogare对象。问题是,如果你?
str = "FieldStorage('myfile', 'file.exe', 'hello\\n')"
obj = eval(str)
解决了我的问题在这种情况下,这是一个_terrible_想法,因为该字符串来自用户。 –
@VincentSavard我绝对同意。 – leongold
你为什么那样做?字符串从哪里来? –
我从一个'unicode(request.post_vars [“myfile”])获得字符串'原因是因为FileStorage不能在JSON中序列化,我需要通过json传递文件@DanielRoseman –
为什么不序列化需要重建对象的参数?为什么你需要序列化整个对象? –