我正在研究一个竞争机器人,它通过sys.stdin接收'输入,并使用Python的print()输出.我有以下内容:
import sys
def main():
while True:
line = sys.stdin.readline()
parts = line.split()
if len(parts) > 0:
# do stuff
Run Code Online (Sandbox Code Playgroud)
问题是输入是通过流进入的,使用上面的方法阻止我打印任何东西直到流关闭.我能做些什么来完成这项工作?
为了通过线路将复杂的 JSON/JavaScript 对象发送到 C++ 二进制文件,我使用了 Protocol Buffers。如今,Node.js 有原生 protobuf 支持,因此我没有使用任何其他绑定。
// Set maximum execution time of binary to equal the
// remainder of processing time, minus a second to allow
// for parsing.
var timeLimit = context.getRemainingTimeInMillis() - 1000;
// Check if meta parameters are given in the request.
// Assign default values if they are not.
var model = new protocols.Model();
// Sort the resolutions.
function descending(a, b) {
if (a.width > b.width) {
return -1;
} else if …Run Code Online (Sandbox Code Playgroud)