我一直得到一个语法错误,并没有能够修复它后,看看无数的网站。我想我一定是漏了什么东西。我以前写过代码,除了这个之外,一切都很正常。我在下面附加了一些代码,并在下面附加了错误信息。我在编码方面还是新手,所以可能没那么清楚。如果有人能帮我那就太好了!
部分代码:
d = dict(0 == 0, I don == 1, "Unknown" == 2, "Unsure" == 3, "Hacking" == 4, "Anonymity" == 5, "Privacy" == 6, "Addiction" == 7, "Catfishing" == 8, "Loss of interest in the real world" == 9,"Headaches" == 10,"Mental health" == 11,"Heart attack" == 12,"Financial collapse" == 13,"Anonymity & online harrassment" == 14,"Dissociation" == 15,"Personal data and privacy terms" == 6,"Addiction and neglecting the real world" == 16,"Scamming" == 17,"Reduce real-life interaction" == 18,"Legal issues" == 19,"Digital property can be damaged more easily" == 20,"I don't use metaverse" == 21,"Program error" == 22,"Scams and sextings" == 23,"Escapicism" == 24,"Mental risks" == 11,"Identity fraud" == 25,"Scammers and sexual predators" == 23,"Scams and catfishing" == 26,"Meeting someone when in reality it's someone else behind a screen" == 8,"Private manners" == 27,"Fraud" == 17,"Cyber bullying" == 28,"Bad advertisement content" == 29,"Wrong knowledgement" == 30,"Reality confusion" == 31,"Security risks & finanical risks" == 32,"Sexual harrassment" == 33,"lag issues" == 34,"Data collection without consent, Addiction" == 35,"Identity theft" == 36,"Wrong investment" == 13,"GDPR" == 37,"Addiction and health probelems" == 38,"Infringement of personal information" == 39,"Crime and anonymity" == 5,"Invasion of privacy" == 6,"Privacy and hacking" == 40,"Crime" == 41,"Unable to distinguish between reality and virtuality" == 31,"Leak of private informations" == 39,"Privacy and security risks that come with technology" == 42,"Losing touch with reality" == 15,"People using it to bully/harrass others" == 43,
"Sex crimes and theft" == 41,
"Deterioration of face to face communication" == 66)错误消息:
Input In [20]
d = dict(0 == 0, I don == 1, "Unknown" == 2, "Unsure" == 3, "Hacking" == 4, "Anonymity" == 5, "Privacy" == 6, "Addiction" == 7, "Catfishing" == 8, "Loss of interest in the real world" == 9,"Headaches" == 10,"Mental health" == 11,"Heart attack" == 12,"Financial collapse" == 13,"Anonymity & online harrassment" == 14,"Dissociation" == 15,"Personal data and privacy terms" == 6,"Addiction and neglecting the real world" == 16,"Scamming" == 17,"Reduce real-life interaction" == 18,"Legal issues" == 19,"Digital property can be damaged more easily" == 20,"I don't use metaverse" == 21,"Program error" == 22,"Scams and sextings" == 23,"Escapicism" == 24,"Mental risks" == 11,"Identity fraud" == 25,"Scammers and sexual predators" == 23,"Scams and catfishing" == 26,"Meeting someone when in reality it's someone else behind a screen" == 8,"Private manners" == 27,"Fraud" == 17,"Cyber bullying" == 28,"Bad advertisement content" == 29,"Wrong knowledgement" == 30,"Reality confusion" == 31,"Security risks & finanical risks" == 32,"Sexual harrassment" == 33,"lag issues" == 34,"Data collection without consent, Addiction" == 35,"Identity theft" == 36,"Wrong investment" == 13,"GDPR" == 37,"Addiction and health probelems" == 38,"Infringement of personal information" == 39,"Crime and anonymity" == 5,"Invasion of privacy" == 6,"Privacy and hacking" == 40,"Crime" == 41,"Unable to distinguish between reality and virtuality" == 31,"Leak of private informations" == 39,"Privacy and security risks that come with technology" == 42,"Losing touch with reality" == 15,"People using it to bully/harrass others" == 43,
^
SyntaxError: invalid syntax发布于 2022-08-21 22:47:00
这段代码有两处错误:
您的字符串之一没有引号(这是您命中的SyntaxError). ),您要将一系列bool参数传递给dict()构造函数,例如,总是将计算值传递给False的"Unsure" == 3 (这是一旦修复了dict()构造函数就会碰到的TypeError )。
将dict指定为文字比使用dict()构造函数容易。做:
d = {
0: 0,
"I don": 1,
"Unknown": 2,
"Unsure": 3,
"Hacking": 4,
"Anonymity": 5,
# etc
}https://stackoverflow.com/questions/73438679
复制相似问题