if __name__ == '__main__': lib_names = dir("url判断.py") def_names = [] file_lib_list=[] with open(os.path.abspath(__file__), "r", encoding="utf-8") as f: for i in f: s = re.findall("(?<=^import).+|(?<=^from).+", i) if len(s): s = s[0] s = s.split(" ")[-1] file_lib_list.append(s)