for st in lineInfo[:]['st']: TypeError: list indices must be integers or slices, not str

有知道这是怎么回事吗?源代码在下面
def save_file(filename, lineInfo):
#print("开始写入文件......")
with open(filename, 'a', encoding='utf-8') as f:
for st in lineInfo['st']:
f.write(st['name'] + " " + st['lat'] + " " + st['lon'] + "\n")

lineInfo[:]['st']列表索引必须是整数或切片,不能是字符。

你lineInfo参数要传的是什么值?
你现在lineInfo传的是列表,列表不能用字符串为下标.
你函数调用时lineInfo参数应该传的是字典吧, lineInfo['st']是访问字典的st键名
你检查下是不是传错值了.
如果lineInfo传的是列表,改成这样试试

def save_file(filename, lineInfo):
    #print("开始写入文件......")
    with open(filename, 'a', encoding='utf-8') as f:
        for st in lineInfo:
            f.write(st['name'] + " " + st['lat'] + " " + st['lon'] + "\n")
def save_file(filename, lineInfo):
    #print("开始写入文件......")
    with open(filename, 'a', encoding='utf-8') as f:
        for st in lineInfo['st']:   列表lineInfo中的'st'要用索引,切片只能用索引,字典才用关键字
            f.write(st['name'] + " " + st['lat'] + " " + st['lon'] + "\n")