繁体   English   中英

由于终端中存在33766的限制,因此如何使用Popen在子进程中读取json文件

[英]How to use Popen to read a json file in subprocess as there is a 33766 limit in terminal

我正在使用此代码在子流程中读取json文件。 如果超过33766,它仅适用于小型json。 它会显示错误

FileNotFoundError: [WinError 206] The filename or extension is too long.

这是因为超过了33766个计数。 因此,如何使用popen读取json文件。读取可以解决此问题。 向我提供建议。 我刚来这地方 :\\

import subprocess
import json
import os

from pprint import pprint

auth = "authorization: token 1234

file = "jsoninput11.json"
fd=open("jsoninput11.json")
json_content = fd.read()
fd.close()


subprocess.run(["grpcurl", "-plaintext","-H", auth,"-d","@",json_content,"-format","json","100.20.20.1:5000","api.Service/Method"])

我不确定,但是问题可能与bufsize (请检查此内容: 使用subprocess.Popen进行非常大的输入和管道传输 )是否可以与capture_output=False

subprocess.run(["grpcurl", "-plaintext","-H", auth,"-d","@",json_content,"-format","json","100.20.20.1:5000","api.Service/Method"], capture_output=False)

另一方面,如果需要输出,则可能需要处理Popen的PIPE。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM