خرید بک لینک

Vote count: 0

I want to use importlib.import_module to import modules dynamically. My code like this:

os.chdir('D:\Python27\Lib\bsddb')
m = importlib.import_module('db')
print dir(m)

I can to this successfully in the Python console. But if I run these code in a fileC:UsersAdministratorDesktop>python test.py, it can't work:

ImportError: No module named db

But if I copy the db.py file to the directory the same as the script file, it works. I can't figure out why.

asked 1 min ago

- - , .
.

برچسب: نویسنده: استخدام کار تاريخ: شنبه 26 تير 1395 ساعت: 19:12

صفحه بندی