Malformed String ValueError ast.literal_eval() with String representation of Tuple
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to read in a string representation of a Tuple from a file, and add the tuple to a list. Here's the relevant code. raw_data = userfile.read().split('\n') for a in raw_data : print a btc_history.append(ast.literal_eval(a)) Here is the output: (Decimal('11.66985'), Decimal('0E-8')) Traceback (most recent call last): File "./goxnotify.py", line 74, in <module> main() File "./goxnotify.py", line 68, in main local.load_user_file(username,btc_history) File "/home/unix-dude/Code/GoxNotify/local_functions.py", line 53, in load_user_file