简体   繁体   English

如何在包/文件夹中的模块中导入一个文件名中带有点的相对导入?

[英]How do I import a module in a package / folder with a dot in the filename for a relative import?

my file organization 我的档案组织

在此处输入图片说明

problem: 问题:

sikuli includes .sikuli as name of folder and doesn't seem to support multiple script files within one folder sikuli包含.sikuli作为文件夹名称,并且似乎在一个文件夹中不支持多个脚本文件

I want to re-use functions from duel.py in duel_all.py 我想重用Duel_all.py中来自duel.py的函数

use shell util to copy the file over and use it 使用shell util复制文件并使用它

import shutil
from os.path import join, dirname, basename
__dirname = dirname(__file__)
shutil.copy(join(__dirname, '..', 'duel.sikuli', 'duel.py'), join(__dirname, 'duel.py'))

from duel import duel

or check out https://stackoverflow.com/a/27556208/3854436 或查看https://stackoverflow.com/a/27556208/3854436

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM