下面的代碼工作正常,作爲一個python代碼(沒有gdb模塊),但它不工作在gdb內部?gdb-python:爲什麼下面的代碼不能在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
關鍵字的問題。
任何人都可以請回復? –