javascript - Python 的 Javascript 等效项 (input())
问题描述
Python:
num = int(input('Please enter a number between 0 to 6'))
def someFunction(num):
# code here
如何在 JavaScript 中做到这一点?
解决方案
如果要在浏览器上运行代码,可以使用 window 的prompt
方法,从用户那里获取输入。
let num = parseInt(prompt("Please enter a number between 0 to 6"))
function someFunction(num){
//code here
}
推荐阅读
- google-sheets - 如何根据电子表格中的数据创建数据透视表?
- python - Python Apache Beam:使用给定文件名写入结果
- python - Python tkinter“KeyPress”和“KeyRelease”事件无法正常工作
- flutter - 在 Flutter 中拒绝来电
- google-chrome - 如何在 Flutter Web 应用程序中滚动时隐藏 chrome 地址栏?
- python - 从 python 到 mysql 的副本集连接
- google-bigquery - 插入到选定的 BigQuery 嵌套列中
- graphics - 如何使角色相对于对象正确绘制,在 Godot 上与对象不同?
- android - 如何为许多应用程序使用 AWS SNS 推送通知
- sql - 如何编写正确的 SQL 查询?