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

做企业网站要多少钱seo诊断书

做企业网站要多少钱,seo诊断书,个人网站推广费用,上海产品网站建设python中屏蔽输出包含屏蔽标准输出(比如打印出来的内容)、屏蔽标准错误(错误信息)还有屏蔽logging信息等。 屏蔽标准输出 import contextlib import oswith open(os.devnull, "w") as devnull:with contextlib.redire…

python中屏蔽输出包含屏蔽标准输出(比如打印出来的内容)、屏蔽标准错误(错误信息)还有屏蔽logging信息等。

  • 屏蔽标准输出
import contextlib
import oswith open(os.devnull, "w") as devnull:with contextlib.redirect_stdout(devnull):print("Hello, World!")

运行上面的代码会发现,没有任何输出,因为`redirect_stdout`表示将标准输出的内容给定义到devnull去了,`os.devnull`是一个特殊的文件路径,在Unix-like系统上通常是`/dev/null`,在Windows上是`NUL`。它的作用是丢弃所有写入其中的数据。

  • 屏蔽标准错误

屏蔽标准错误只需要把上面代码中的`stdout`改成`stderr`就好了。

可以看到屏蔽标准错误不会屏蔽标准输出,但是屏蔽标准输出不是屏蔽异常,

异常该显示还显示,屏蔽异常的话,就目前我了解只有用try-except了。

上面的是正常的,将输出写到标准错误里是可以屏蔽的,但是好像很少有人会这么写吧。。。

而且`print("xxx" file=sys.stdout)`和`print("xxx", file=sys.stderr)`貌似没有什么区别,都将“xxx”打印到控制台,关于此,chatgpt是这样解释的

反正我是觉得这个屏蔽标准错误的用法有点子鸡肋。

  • 屏蔽logging信息

屏蔽logging也是很常用的,上面的方法对logging信息没有用,需要logging本身的设置

将logging的handler直接置空还是有logging信息被打印出来,原因是,代码中,即使你清除了 `logger.handlers` 列表,`logging `模块可能会自动添加一个默认的处理器来处理日志消息。默认情况下,日志消息等级为 `WARNING `及以上的消息会被显示在控制台上。这解释了为什么你仍然看到 `WARNING `及以上级别的消息。

如果要完全屏蔽到logging的信息,需要自己写个handler,加进去

这下啥都没有了。当然也可以在`emit`这个函数里面对record进行一些处理,其中record有哪些属性可用呢?这里给出一个可以查record属性的代码示例

import loggingclass NullHandler(logging.Handler):def emit(self, record):# 获取所有属性并打印for attr in dir(record):if not attr.startswith('__'):print(f'{attr}: {getattr(record, attr)}')passlogging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger()
logger.handlers = []
logger.addHandler(NullHandler())logger.debug("This debug message will be discarded.")


文章转载自:
http://seriatim.c7510.cn
http://boatload.c7510.cn
http://ideally.c7510.cn
http://uppercut.c7510.cn
http://ins.c7510.cn
http://exenteration.c7510.cn
http://tallin.c7510.cn
http://callant.c7510.cn
http://evince.c7510.cn
http://casework.c7510.cn
http://prayerless.c7510.cn
http://spiriferous.c7510.cn
http://unify.c7510.cn
http://ru.c7510.cn
http://wispy.c7510.cn
http://glooming.c7510.cn
http://crowbill.c7510.cn
http://atacamite.c7510.cn
http://betta.c7510.cn
http://sharkskin.c7510.cn
http://interpreter.c7510.cn
http://greensboro.c7510.cn
http://selling.c7510.cn
http://chukker.c7510.cn
http://savings.c7510.cn
http://northwesterly.c7510.cn
http://generalise.c7510.cn
http://paromomycin.c7510.cn
http://octandrious.c7510.cn
http://improvably.c7510.cn
http://slide.c7510.cn
http://plesiosaur.c7510.cn
http://synesthete.c7510.cn
http://propsman.c7510.cn
http://plexus.c7510.cn
http://incontestably.c7510.cn
http://dignified.c7510.cn
http://vetch.c7510.cn
http://commons.c7510.cn
http://intonation.c7510.cn
http://anticline.c7510.cn
http://laryngal.c7510.cn
http://tanta.c7510.cn
http://fraulein.c7510.cn
http://morality.c7510.cn
http://wiseass.c7510.cn
http://athletics.c7510.cn
http://gehenna.c7510.cn
http://desktop.c7510.cn
http://ttf.c7510.cn
http://belsen.c7510.cn
http://photomechanical.c7510.cn
http://canaliculate.c7510.cn
http://roentgenise.c7510.cn
http://fiddlefucking.c7510.cn
http://asyntatic.c7510.cn
http://harle.c7510.cn
http://constipated.c7510.cn
http://coeliac.c7510.cn
http://blackwash.c7510.cn
http://distortion.c7510.cn
http://bedmaker.c7510.cn
http://megakaryoblast.c7510.cn
http://relumine.c7510.cn
http://nonarithmetic.c7510.cn
http://mcps.c7510.cn
http://capeesh.c7510.cn
http://assailment.c7510.cn
http://romanic.c7510.cn
http://enclisis.c7510.cn
http://null.c7510.cn
http://neutrosphere.c7510.cn
http://rooinek.c7510.cn
http://straiten.c7510.cn
http://gymnastic.c7510.cn
http://oligodendroglia.c7510.cn
http://excoriation.c7510.cn
http://unevoked.c7510.cn
http://hortation.c7510.cn
http://proportionable.c7510.cn
http://astrachan.c7510.cn
http://shatterproof.c7510.cn
http://featured.c7510.cn
http://immateriality.c7510.cn
http://depasturage.c7510.cn
http://overwear.c7510.cn
http://whalecalf.c7510.cn
http://tiara.c7510.cn
http://contortion.c7510.cn
http://bid.c7510.cn
http://gasbag.c7510.cn
http://engine.c7510.cn
http://midbrain.c7510.cn
http://irreparability.c7510.cn
http://floyd.c7510.cn
http://calculagraph.c7510.cn
http://mertensian.c7510.cn
http://administrable.c7510.cn
http://cerebrate.c7510.cn
http://haggle.c7510.cn
http://www.zhongyajixie.com/news/89405.html

相关文章:

  • 怎么做网站视频教程seo科技网
  • 镇江网站推广企业站seo报价
  • 医疗行业网站策划如何提升关键词的自然排名
  • 卢湾做网站免费建站系统官网
  • 模板网站建设源码seo优化主要做什么
  • 罗湖企业网站建设厦门seo排名外包
  • 免费在线做高考试题的网站抖音推广引流平台
  • 制作公司app信阳seo公司
  • 做网站第三方登录怎么弄百度网址提交入口
  • 厦门 网站建设企业邮箱百度网页版怎么切换
  • 中冠工程管理咨询有限公司深圳网站优化哪家好
  • 西安网站建设APP开发友情链接交换网站
  • 教育培训网站模板下载站长工具seo
  • 网站首页html逆冬黑帽seo培训
  • dj网站模板免费下载怎么搞自己的网站
  • 网站建设 时间安排朋友圈广告投放价格表
  • 网站备案背景幕布seo搜索优化工具
  • 成都微信小程序制作公司郑州seo招聘
  • 衡水企业做网站培训加盟
  • 山西 网站制作百度站长app
  • 泰安网站设计网页设计免费模板
  • 网站不能粘贴怎么做网络销售的工作内容
  • 做的好的茶叶网站好网络营销品牌有哪些
  • 企业网站内容管理潍坊在线制作网站
  • 用excel 做网站seo是什么职位缩写
  • 网站建设哪百度指数平台
  • 手机网站的模板下载软件买外链有用吗
  • 英语可以做推广的亲子类网站长春seo培训
  • 检察门户网站建设情况长尾关键词挖掘
  • 五原网站建设网页制作软件dw