google-chrome - 如何将数组列表从 chrome 扩展发送到我的 python 应用程序?
问题描述
我正在尝试使用本机消息 api 将数组列表从 chrome 扩展发送到我的本机 python 应用程序。
背景脚本.js
port = window.browser.runtime.connectNative(hostName);
port.postMessage(request.attributes);
我的应用程序.py
text_length_bytes = sys.stdin.read(4)
text_length = struct.unpack('i', bytes(text_length_bytes, 'utf-8'))[0]
text = sys.stdin.read(text_length)
当我在帖子消息中发送数组列表作为属性时,chrome 扩展程序和本机 python 应用程序之间的连接停止,但是当我将字符串作为属性时它可以工作。
解决方案
推荐阅读
- javascript - GraphQL + firebase 问题
- java - JAVA InputStream.toString() 返回 InputStream
- isabelle - 在结构归纳证明中概括一个主张,以便能够使用归纳假设
- javascript - 试图创建一个可以提供包含表单数据的打印窗口的表单
- azure-devops - 配置有效的服务端点
- kubernetes - 在 Istio 中,服务到服务的通信,是否需要设置 Kubernetes 服务?
- c# - 是否有必要取消订阅拥有对象的事件处理程序?
- python-3.x - 从熊猫系列中的字符串列表中删除空格
- django - 如何在 Godaddy 专用服务器(豪华版)上托管我的 django 应用程序?
- python - KFold 交叉验证不能修复过度拟合