如何解决python sys路径添加和插入
我在文件夹a和b中有两个名为test_def.py的python脚本。
在文件夹a的test_def.py中:
*def hello_function():
print ('hello! aaa')*
在文件夹b的test_def.py中:
*def hello_function():
print ('hello! 'bbb')*
#case 1
*os.chdir(folder a)
sys.path.append(folder b")
from test_def import *
hello_function()*
#你好! aaa
#case 2
os.chdir(folder a)
sys.path.insert(1,folder b)/ or sys.path.insert(0,folder b)
from test_def import *
hello_function()
#你好! bbb
#case 3
os.chdir(folder a)
from test_def import *
sys.path.insert(1,folder b)
from test_def import * #import again
hello_function()
#你好! aaa
在上述三种情况下,谁能让我知道阅读脚本的python搜索的区别?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。