0

以下のコードは 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
...
...

withandasキーワードに問題があるようです。

4

1 に答える 1