[英]SyntaxError: EOL while scanning string literal
I am getting a Syntax Error EOL on the print line.我在打印行收到语法错误 EOL。 I tried adding more commas but it wont work.
我尝试添加更多逗号,但它不起作用。
def getAuthorized(url, username, password):
r = requests.get(url, auth=(username, password))
if str(r.status_code) != '401':
print "\n[!] Username: " + username + " Password: " + password + "
Code: " + str(r.status_code) + "\n"
Thank you in advance!!先感谢您!!
Adding commas will not work.添加逗号将不起作用。 The Problem Here is that:
这里的问题是:
def getAuthorized(url, username, password):
r = requests.get(url, auth=(username, password))
if str(r.status_code) != '401':
print "\n[!] Username: " + username + " Password: " + password + "
Code: " + str(r.status_code) + "\n"
You can split the print into two lines, but I don't suggest you to.您可以将打印分成两行,但我不建议您这样做。 The print line should be:
打印行应该是:
print "\n[!] Username: " + username + " Password: " + password + " Code: " + str(r.status_code) + "\n"
So the final code should be:所以最终的代码应该是:
def getAuthorized(url, username, password):
r = requests.get(url, auth=(username, password))
if str(r.status_code) != '401':
print "\n[!] Username: " + username + " Password: " + password + " Code: " + str(r.status_code) + "\n"
The problem is in "…Code: "
— Python doesn't allow to make a single-quoted string multiline;问题出在
"…Code: "
中——Python 不允许单引号字符串多行; only triple-quoted strings can be multiline.只有三引号字符串可以是多行的。 To fix:
修理:
print "\n[!] Username: " + username + " Password: " + password + \
" \n Code: " + str(r.status_code) + "\n"
Please note a backslash at the end of the first line: it's required to continue the statement print
on the next line.请注意第一行末尾的反斜杠:它需要在下一行继续
print
语句。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.