Spaces:
Sleeping
Sleeping
| import re | |
| def find_imports(code): | |
| pattern = r'Python\.import_module\("([^"]*)"\)' | |
| matches = re.findall(pattern, code) | |
| return matches | |
| if __name__ == "__main__": | |
| code = ''' | |
| from python import Python | |
| Python.import_module("numpy") | |
| Python.import_module("pandas") | |
| Python.import_module("matplotlib") | |
| def main(): | |
| print("hello world") | |
| ''' | |
| print(find_imports(code)) # Output: ['numpy', 'pandas', 'matplotlib'] |