我不想在Javascript中运行Python代码,我想将其完全转换为JS代码。我不知道python,Can body可以帮助我。谢谢。
print ("Please input the # of books you've read this year")
BooksAlready=int(input())
print ("Please input the # of weeks that have already passed this year")
WeeksAlready=int(input())
x=(78/52)
c=x*WeeksAlready-BooksAlready
if (BooksAlready/WeeksAlready)>x:
print ("You're on point, go have some fun!")
else:
print ("Go read, you piece of uneducated crap")
print ("You have")
print (c)
print ("books left to read this week to get on point")
答案 0 :(得分:1)
这将在浏览器的js控制台中运行。 prompt
在node.js中不起作用,您可以使用process.argv
访问命令行参数。
console.log("Please input the # of books you've read this year");
console.log("Please input the # of weeks that have already passed this year");
var WeeksAlready=parseInt(prompt()),
BooksAlready=parseInt(prompt()),
x=(78/52),
c=x*WeeksAlready-BooksAlready;
if (BooksAlready/WeeksAlready>x){
console.log("You're on point, go have some fun!");
}
else{
console.log ("Go read, you piece of uneducated crap");
console.log ("You have");
console.log (c);
console.log ("books left to read this week to get on point");
}
答案 1 :(得分:0)
请查看以下链接,了解有关从python到js的转换器的更多信息。