一個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 –
爲什麼不序列化需要重建對象的參數?爲什麼你需要序列化整個對象? –