大佬教程收集整理的这篇文章主要介绍了python3 对 <class 'bytes'> 类型的 post_body 执行 re.sub?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Json.loads(posT_Body) 得到了 "TypeError: a bytes-like object is required,not 'str'"
目标是让 posT_Body 没有实际的 pwd=secret 和 password=secret 信息,但被 xx 取代
请指教。谢谢。
self.server.logger.info(Json.loads(posT_Body)) #if "password" in Json.loads(posT_Body): # posT_Body = re.sub(r"(.*)(pwd=)([a-z,A-Z,0-9]+)(\",\s+)(\"password\":\s+\")(\w+)(.*)",r"\1\2xx\4\5xx\7",str(Json.load(posT_Body))) ??? # Send Event to Splunk via event_writer self.server.output_results(Json.loads(posT_Body),self.client_address[0])
@H_673_13@解决方法
想出了以下内容:
self.server.logger.info(json.loads(posT_Body)) if "password" in posT_Body.decode("utf-8"): posT_Body_d = re.sub(r"(.*)(pwd=)([a-z,A-Z,0-9]+)(\",\s+)(\"password\":\s+\")(\w+)(.*)",r"\1\2xx\4\5xx\7",posT_Body.decode("utf-8")) posT_Body = posT_Body_d.encode("utf-8") # Send Event to Splunk via event_writer self.server.output_results(json.loads(posT_Body),self.client_address[0])
@H_673_13@大佬总结
以上是大佬教程为你收集整理的python3 对 <class 'bytes'> 类型的 post_body 执行 re.sub?全部内容,希望文章能够帮你解决python3 对 <class 'bytes'> 类型的 post_body 执行 re.sub?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。