当前位置: 首页 > news >正文

家庭宽带做网站设计院

家庭宽带做网站,设计院,网站建立需要什么技术,单页网站制作 在线 支付目录 需求#xff1a;如何将pkg02/test02.py导入pkg01/test01.py中#xff1f; 方法1#xff1a;使用importlib模块动态导入 对于Python 3.5 对于Python 3.3、3.4 对于Python 2 方法2#xff1a;使用runpy模块动态导入 方法3#xff1a;修改sys.path变量 需求如何将pkg02/test02.py导入pkg01/test01.py中  方法1使用importlib模块动态导入 对于Python 3.5 对于Python 3.3、3.4 对于Python 2 方法2使用runpy模块动态导入 方法3修改sys.path变量 需求如何将pkg02/test02.py导入pkg01/test01.py中  方法1使用importlib模块动态导入 对于Python 3.5 ## pkg01/test01.py import importlib.util spec importlib.util.spec_from_file_location(test02, /root/demo/pkg02/test02.py) module importlib.util.module_from_spec(spec) spec.loader.exec_module(module) print(module) print(module.args) module.fun() module.TestA().testa()## pkg02/test02.py print(导入demo/pkg02/test02.py) args {a: 100} def fun():print(func in demo/pkg02/test02.py) class TestA:def testa(self):print(TestA.testa in demo/pkg02/test02.py)对于Python 3.3、3.4 ## pkg01/test01.py from importlib.machinery import SourceFileLoader loader SourceFileLoader(test02, /root/demo/pkg02/test02.py) module loader.load_module() print(module) print(module.args) module.fun() module.TestA().testa()## pkg02/test02.py print(导入demo/pkg02/test02.py) args {a: 100} def fun():print(func in demo/pkg02/test02.py) class TestA:def testa(self):print(TestA.testa in demo/pkg02/test02.py) 对于Python 2 ## pkg01/test01.py import imp module imp.load_source(test02, /root/demo/pkg02/test02.py) print(module) print(module.args) module.fun() module.TestA().testa()#codingutf-8 ## pkg02/test02.py print(导入demo01/pkg02/test02.py) args {a: 100} def fun():print(func in demo01/pkg02/test02.py) class TestA:def testa(self):print(TestA.testa in demo01/pkg02/test02.py)方法2使用runpy模块动态导入 ## pkg01/test01.py from runpy import run_path settings run_path(/root/demo/pkg02/test02.py) print(settings[args]) settings[fun]() settings[TestA]().testa() ## pkg02/test02.py print(导入demo/pkg02/test02.py) args {a: 100} def fun():print(func in demo/pkg02/test02.py) class TestA:def testa(self):print(TestA.testa in demo/pkg02/test02.py) 方法3修改sys.path变量 ## pkg01/test01.py import sys,os cur_dir os.path.dirname(os.path.abspath(__file__)) sys.path.append(os.path.dirname(cur_dir)) print(sys.path) from pkg02 import test02 print(test02) print(test02.args) test02.fun() test02.TestA().testa() ## pkg02/test02.py print(导入demo/pkg02/test02.py) args {a: 100} def fun():print(func in demo/pkg02/test02.py) class TestA:def testa(self):print(TestA.testa in demo/pkg02/test02.py)
http://www.hkea.cn/news/14474928/

相关文章:

  • 做试管的网站app软件制作器
  • 工信部网站备案流程大学网站建设策划书
  • 网站制作行业越来越难做微信怎么弄自己的商城
  • 阿里云网站建设的实训报告运维难还是开发难
  • 楚雄建网站贵阳网站建设公司排名
  • 网站有什么模块太原市建站外包公司
  • 做一个公司网站一般多少钱自己做网站还有出路吗
  • 小说网站做编辑微信公众号如何发布wordpress
  • 网站怎么做子页吉利汽车网站开发环境分析
  • 厦门景观绿环建设行业协会网站长沙大的建网站公司
  • 烟台高新区网站网上智慧团建系统入口
  • 江西正东建设工程有限公司网站a wordpress
  • 重庆知名做网站的公司景点网站应该怎么做
  • 凡科建站是不是免费的可信的专业网站建设
  • 网站开发 技术问题wordpress导航图标
  • 网站建设怎么更换图片网页设计技术学什么
  • 个人空间网站模板统一管理网站系统
  • 建个企业网站一年多少钱国外超酷网站
  • 能看任何网站的浏览器网站栏目模版
  • 推荐一些做电子的网站毕业设计网站做啥
  • 用asp做宠物网站页面网络设计方案包括哪些方面
  • 专业做京东网站吗网站维护中 html
  • 成都企业建网站网站seo优化分析
  • 土木特网站建设网页制作软件哪里有
  • 江西省城乡建设厅网站网站免费空间
  • 建设银行如何网站设置密码西陆网
  • 做推广可以上那些网站微信最火的公众号排行
  • 中国铁路建设监理协会官方网站网站怎么做qq登录
  • 网站开发后台需要自己写吗简单免费模板
  • 淄博培训网站建设织梦网站一级目录