下面的代码工作正常的Python代码(不GDB模块),但它不GDB内部的工作?
#!/usr/bin/env python
import csv
import gdb
list = []
x = open("file.txt")
with x as csv_data:
entries = csv.reader(csv_data, delimiter=",")
for entry in entries:
list.append({
"name": entry[0],
"type": entry[1],
"link": entry[2],
"level": entry[3]
})
错误的是:
(gdb) source script.py
File "script.py", line 6
with x as csv_data:
^
SyntaxError: invalid syntax
file.txt的是:
Mac, char, list, one
John, char, list, three
...
...
似乎有问题,与with
和as
关键字。