搭建Reddit Video Maker Bot时出现语法错误的技术求助
Ah, I spot the issue right away—this is a simple typo that's throwing off the entire syntax before your for loop even gets to run.
The Exact Culprit
Look at this line in your code:
content["comments"7] = []
That stray 7 tacked onto the end of "comments" is invalid Python syntax for a dictionary key. The interpreter can't make sense of this line, so it flags the very next line (your for loop) as the error, even though the loop itself is perfectly fine.
The Quick Fix
Just remove that extra 7 to make the dictionary key valid:
content["comments"] = []
Why This Happened
Python requires dictionary keys to be valid expressions—like a string in quotes, a number, or a variable. "comments"7 is a broken combination of a string and a number with no operator connecting them, so the parser chokes on it. This is a super easy typo to make, especially when you're copying or editing code quickly!
A Quick Double-Check
Once you fix this, your code should move past the syntax error and start iterating over the Reddit comments as expected. It's a good idea to scan through any other dictionary assignments in the file to make sure there aren't similar typos hiding elsewhere—they're sneaky!
内容的提问来源于stack exchange,提问作者WSPlayZ _

