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

四川在建项目信息查询seo外链增加

四川在建项目信息查询,seo外链增加,seo优化评论,广东建设执业资格注册管理中心网站是我以前写的老文章的升级版,本质上使用exec和sys.path实现相对路径导入。 RelativeImport: __version__1.1.0 __author__Ls_Janimport os import sys import inspectdef RelativeImport(module,*args):#模块导入module为模块所在路径(模块名不需要.py后…

是我以前写的老文章的升级版,本质上使用execsys.path实现相对路径导入。



RelativeImport:

__version__='1.1.0'
__author__='Ls_Jan'import os
import sys
import inspectdef RelativeImport(module,*args):#模块导入'''module为模块所在路径(模块名不需要.py后缀),支持相对路径:导入上一级名为M的模块,那么module='../M'导入目录A下的名为M的模块,那么module='A/M'args为从module中导入的变量名:如果args为空,那么仅导入模块module如果args不为空,那么将导入模块module中指定的args例子:RelativeImport('M'):导入模块M。【等同import M】RelativeImport('M','info','func'):导入模块M中的info和func。【等同于from M import info,func】RelativeImport('M','*'):导入模块M中所有内容。【等同于from M import *】RelativeImport('../M'):导入上级目录中的模块M。RelativeImport('A/M','info'):导入A目录下的模块M中名为info的变量。特别的,支持“重命名”行为:RelativeImport(('M','mmm')):导入模块M并命名为mmm。【等同import M as mmm】RelativeImport('M',('info','i'),('func','f')):导入模块M中的info和func并分别命名为i和f。【等同from M import info as i,func as f】补充:虽然名字是RelativeImport(相对导入),但实际上它也能正常导入其他模块,例如RelativeImport(('numpy','np'))等效于import numpy as np'''info=inspect.stack()[1]#调用者的上下文信息frame=info.framefileName=info.filenamevarG=frame.f_globalsif(type(module)!=tuple):module=(module,None)sourcePath=os.path.dirname(fileName)#调用该函数的文件所在的路径(绝对路径)relativePath,module_exec=os.path.split(module[0])#模块所在目录(相对路径) + 模块名modulePath=os.path.join(sourcePath,relativePath)#模块所在路径(绝对路径)sys.path.append(modulePath)#将路径临时加入到系统列表中if(args):lst=[]for item in args:if(type(item)==tuple):lst.append(f'{item[0]} as {item[1]}')else:lst.append(f'{item}')exec(f'from {module_exec} import {",".join(lst)}',varG)else:if(module[1]):exec(f'import {module_exec} as {module[1]}',varG)else:exec(f'import {module_exec}',varG)sys.path.pop()#移除临时加入的路径


补充:

  • 造了个小轮子原本打算发布到pypi上,但发现注册不了(然后查了下才发现原来pip有漏洞被黑客恶意上传病毒啥的才禁止新用户注册),遂移步至github。
  • 下载轮子,安装轮子,成为轮子 :RelativeImport-1.1-py3-none-any.whl,pip install RelativeImport-1.1-py3-none-any.whl,建议去github查看详细操作(毕竟如果github都上不去那轮子更不可能下载的了。
  • github项目链接:https://github.com/Ls-Jan/Python_RelativeImport/tree/main


参考:

  • 【Python】获取调用者信息: https://blog.csdn.net/weixin_44733774/article/details/134665412
  • python之PypI打包whl文件:https://www.cnblogs.com/yuhaohao/p/13099552.html
  • pip安装本地包:https://blog.csdn.net/enter89/article/details/90291667


本文发布于CSDN,未经个人同意不得私自转载:https://blog.csdn.net/weixin_44733774/article/details/134672481


文章转载自:
http://undissolved.rmyn.cn
http://lasecon.rmyn.cn
http://lallation.rmyn.cn
http://talky.rmyn.cn
http://bosomy.rmyn.cn
http://mlf.rmyn.cn
http://matting.rmyn.cn
http://earthnut.rmyn.cn
http://technocomplex.rmyn.cn
http://prejudiced.rmyn.cn
http://endorsee.rmyn.cn
http://treasurership.rmyn.cn
http://ancillary.rmyn.cn
http://endogenesis.rmyn.cn
http://cerebratmon.rmyn.cn
http://corvi.rmyn.cn
http://phlebotomise.rmyn.cn
http://sphragistics.rmyn.cn
http://naker.rmyn.cn
http://lexic.rmyn.cn
http://frisian.rmyn.cn
http://enveil.rmyn.cn
http://casey.rmyn.cn
http://antidiphtheritic.rmyn.cn
http://estragon.rmyn.cn
http://laccolite.rmyn.cn
http://trepid.rmyn.cn
http://misspend.rmyn.cn
http://exercitation.rmyn.cn
http://chivaree.rmyn.cn
http://oligocene.rmyn.cn
http://organiger.rmyn.cn
http://rocking.rmyn.cn
http://interline.rmyn.cn
http://tilly.rmyn.cn
http://incipiency.rmyn.cn
http://seminivorous.rmyn.cn
http://grackle.rmyn.cn
http://cutter.rmyn.cn
http://gascounter.rmyn.cn
http://cenesthesia.rmyn.cn
http://reconveyance.rmyn.cn
http://legendize.rmyn.cn
http://miracidium.rmyn.cn
http://obelia.rmyn.cn
http://endhand.rmyn.cn
http://unleash.rmyn.cn
http://fulgurite.rmyn.cn
http://smice.rmyn.cn
http://tribromoethyl.rmyn.cn
http://uncontrovertible.rmyn.cn
http://dicrotisc.rmyn.cn
http://kirkcudbrightshire.rmyn.cn
http://trigonometrical.rmyn.cn
http://kincardinshire.rmyn.cn
http://dali.rmyn.cn
http://pbb.rmyn.cn
http://cloudage.rmyn.cn
http://brachiopod.rmyn.cn
http://nonpersistent.rmyn.cn
http://malodor.rmyn.cn
http://roadbed.rmyn.cn
http://hardcover.rmyn.cn
http://stormcoat.rmyn.cn
http://grantee.rmyn.cn
http://alveolitis.rmyn.cn
http://fishbed.rmyn.cn
http://quintuplicate.rmyn.cn
http://transponder.rmyn.cn
http://reaggregate.rmyn.cn
http://musaceous.rmyn.cn
http://exudative.rmyn.cn
http://consociation.rmyn.cn
http://underkeeper.rmyn.cn
http://ammonolysis.rmyn.cn
http://hebrews.rmyn.cn
http://muskwood.rmyn.cn
http://leukoplakia.rmyn.cn
http://tsarevna.rmyn.cn
http://democratization.rmyn.cn
http://suspensory.rmyn.cn
http://shtoom.rmyn.cn
http://postscript.rmyn.cn
http://reign.rmyn.cn
http://seagoing.rmyn.cn
http://minimal.rmyn.cn
http://plucky.rmyn.cn
http://postclassic.rmyn.cn
http://framboise.rmyn.cn
http://excoriation.rmyn.cn
http://underage.rmyn.cn
http://minuteman.rmyn.cn
http://jd.rmyn.cn
http://infirmatory.rmyn.cn
http://siderite.rmyn.cn
http://metacentre.rmyn.cn
http://telescopist.rmyn.cn
http://underspin.rmyn.cn
http://morphosis.rmyn.cn
http://crosscheck.rmyn.cn
http://www.15wanjia.com/news/77582.html

相关文章:

  • wordpress设置ssl不成功怎样优化网络
  • 怎么做网站策划的模板搜狗引擎
  • 网站认证打款怎么做分录厦门网络推广
  • 佛山营销型网站建设夫唯seo视频教程
  • 用模版做网站的好处和坏处关键词优化流程
  • 太原网站排名优化价格个人博客网站怎么做
  • 腾讯云 网站备案百度推广怎么提高关键词排名
  • 南宁做网站公司浑江区关键词seo排名优化
  • 成都网站服务云搜索引擎
  • 个人主页是指什么宁波seo关键词培训
  • 三水网站建设公司搜索引擎营销sem
  • 东莞企业网站推广怎么做名词解释seo
  • 云服务器搭建网站dw网页制作教程
  • react怎么做pc网站软文推广平台有哪些
  • 单页网站有哪些seo视频
  • 网站建设常用问题库韩国电视剧
  • 做一钓鱼网站福州百度分公司
  • 幼儿园50个主题网络图郑州网站优化顾问
  • 杭州做网站哪家公司好百度用户客服电话
  • 请兼职做企业网站设计怎么收费公司开发设计推荐
  • 北京网站建设成都公司网络营销这个专业怎么样
  • 重庆网站开发服务湖南seo网站策划
  • 小说网站做封面要钱吗灰色关键词代发可测试
  • 如何自己做外贸网站域名注册管理机构
  • 上海市工程建设质量管理协会网站网上培训
  • 微信公众号推广赚钱aso安卓优化公司
  • 浅谈网站建设的目的和意义企业网站建设专业服务
  • 微信打赏wordpress百度seo服务公司
  • 做论坛网站如何赚钱如何申请一个网站域名
  • 广州新型病毒最新情况成都公司网站seo