Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

python; import a file as the result of an argument [duplicate]

$
0
0

I have to write a little python program.I have to import a file but this file will be done by the client.for exemple here is test.py:

import getoptimport sysparams=[]options remainder =getopt.getopt(sys.argv[i:], 'f:t',['test'])for opt, arg in options:    if opt in ('-f','files'):        files=argprint (files)import files

but when I run it:

python test.py -f myFileTrceback (most recent call last):    File "test.py", line 14, in <module>        import filesModuleNotFoundError: No module named 'files'

Thank in advance for your help


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>