我现在已经问过这个问题,但是他们没有任何问题 解决方案。
这是我的测试代码:
//starting JSON
let trivia = [*JSON*];
//iterate over your JSON
for (let i = 0; i < trivia.length; i++) {
//print the question
document.getElementById("container").appendChild(document.createTextNode(trivia[i].question));
document.getElementById("container").appendChild(document.createElement("br"));
//iterate over the choices and create answer objects
for (let i2 = 0; i2 < trivia[i].choices.length; i2++) {
//print the choices
var input = document.createElement("input");
input.type = "radio";
input.value = trivia[i].choices[i2];
input.name = trivia[i].question;
document.getElementById("container").appendChild(input);
document.getElementById("container").appendChild(document.createTextNode(trivia[i].choices[i2]));
document.getElementById("container").appendChild(document.createElement("br"));
};
//seperate questions
document.getElementById("container").appendChild(document.createElement("br"));
document.getElementById("container").appendChild(document.createElement("br"));
};
//test the submitted answer against the stored value
function testAnswers(){
let score = 0;
for (let i = 0; i < trivia.length; i++) {
let questionSelectedAnswer = getRadioValue(trivia[i].question);
if (questionSelectedAnswer == trivia[i].answer){
score++;
}
}
alert("You scored " + score + "/" + trivia.length);
}
//get the selected value for a collection of answers
function getRadioValue(theRadioGroup)
{
var elements = document.getElementsByName(theRadioGroup);
for (var i = 0, l = elements.length; i < l; i++)
{
if (elements[i].checked)
{
return elements[i].value;
}
}
}
//set the timer logic
var timer;
function startTimer() {
//clear any running timers
clearInterval(timer);
var secondsRemaining = 60;
timer = setInterval(function() {
secondsRemaining--;
// If the count down is over run the test
if (secondsRemaining < 1) {
clearInterval(timer);
testAnswers();
secondsRemaining = 0;
}
//print the time
document.getElementById("timer").innerHTML = secondsRemaining + " seconds remaining";
}, 1000);
}
我检查了用户名和密码是否正确,并已将其与帐户相关联。
我的错误:
import praw
reddit = praw.Reddit(client_id='*****',
client_secret='******',
user_agent='******',
username="correct_username",
password="correct_password")
for post in reddit.subreddit('all').stream.submissions():
print(post)
我可以使用刷新令牌进行连接,但是我的项目需要多个机器人。我不想为所有机器人找到刷新令牌。会很无聊的。我只想用用户名和密码登录。