search

Home  >  Q&A  >  body text

python - pycharm return outside of function

class data_list:
    file_list = os.listdir(os.getcwd())
    data_file = []
    for i in file_list:
        if i.endswith('.js'):
            data_file.append(i)
    return data_file

I don’t know why this error is reported. May I ask what is wrong?

巴扎黑巴扎黑2756 days ago1044

reply all(1)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-18 11:00:28

    What you defined above is a classclass data_list, not a function.

    reply
    0
  • Cancelreply