Hi how do I import files inside a txt file?

Tobiah toby at tobiah.org
Mon Sep 30 11:58:07 EDT 2019


On 9/2/19 3:32 AM, Spencer Du wrote:
> Hi
> 
> How do i import files inside a txt file if they exist in the current
> directory?
> 

Once you've read the module names you can use:

   new_module = __import__(modulename)

So you'd read the name from your file into
modulename and import the name contained in
that variable in this way.







More information about the Python-list mailing list