python:没有输出或只产生一个空列表 [英] python : no output or only an empty list was produced

查看:56
本文介绍了python:没有输出或只产生一个空列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

index1 = 0
singlechar = []
def SINGLE_CHAR_VAR(filename):
    firdict = vars_indents(filename)[0]
    firtup_keys = firdict.keys()
    firtup_val = firdict.values()
    for keys in firtup_keys:
        for values in firtup_val:
            index = 0
            for index in range(len(values)):
                firvallist = firtup_val[index]
                for item in firvallist:
                    if len(item[0]) == 1:
                        singlechar.append({'ERROR_TYPE': 'SINGLE_CHAR_VAR', 'LINE_NUMBER': str(keys),'COLUMN': str(item[1]),'INFO': str(item[0]),'SOURCE_LINE': str(lines[keys - 1])})
                    else:
                        continue
                return singlechar

这是我的代码,但没有产生任何输出,或者当我在 return 语句周围移动时,产生了一个空列表.我希望它能给我一个字典列表作为输出.

this is my code but there is no output produced or when i move around the return statement an empty list was produced. i was hoping it to give me a list of dictionaries as the output.

有人可以教我如何解决这个问题吗?

can somebody teach me how to fix this?

谢谢

推荐答案

您应该首先调用该函数以获取输出.

You should call the function at first to get the output.

SINGLE_CHAR_VAR(filename)

你怎么能期望一个函数在不被调用的情况下运行?

这篇关于python:没有输出或只产生一个空列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆