有没有办法用JavaScript读取标准输入? [英] Is there a way to read standard input with JavaScript?

查看:54
本文介绍了有没有办法用JavaScript读取标准输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在其他许多语言中都看到了这一点,但JavaScript却没有.

I saw this for lots of other languages but not JavaScript.

我正在尝试做这样的问题:this(codechef.com),当然程序也需要能够像C ++和其他语言一样阅读标准.

I'm trying to do problems like: this (codechef.com) and of course the programs need to be able to read standard in like C++ and other languages do.

感谢您的回答.我想要此功能的主要原因是可以回答CodeChef上的问题.Codechef将多个输入发送到作为答案的文件/程序(当然,程序必须以要求的方式响应才能使答案正确).

Thanks for the answers. The primary reason I want this functionality is so I can answer the questions on CodeChef; Codechef sends multiple inputs to the files/programs that are the answers (and of course the programs have to respond in the required way for the answer to be correct).

推荐答案

这取决于JavaScript在其中执行的环境.

It depends on the environment that your JavaScript is executing in.

在浏览器中,没有标准输入(浏览器不是控制台).输入通常来自页面形式的某些文本框元素.

In the browser, there is no standard input (the browser isn't a console). The input would come generally from some textbox element in a form on the page.

如果您使用的是犀牛之类的东西,则可以导入标准Java I/O类并以这种方式从stdin中读取(,请参见第二个例如 不再出现在Wiki上.

If you're using something like Rhino, then you can import the standard Java I/O classes and read from stdin that way (see the second example no longer on the wiki).

这篇关于有没有办法用JavaScript读取标准输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆