为什么Python print在第9行的简单语句中给出了语法错误?
import hashlib, sys
m = hashlib.md5()
hash = ""
hash_file = raw_input("What is the file name in which the hash resides? ")
wordlist = raw_input("What is your wordlist? (Enter the file name) ")
try:
hashdocument = open(hash_file,"r")
except IOError:
print "Invalid file." # Syntax error: invalid syntax
raw_input()
sys.exit()
else:
hash = hashdocument.readline()
hash = hash.replace("\n","")
Run Code Online (Sandbox Code Playgroud)
Python的版本是:
Python 3.2.2 (default, Sep 4 2011, 09:07:29) [MSC v.1500 64 bit (AMD64)] on win
32
Run Code Online (Sandbox Code Playgroud) 我正在对服务器执行远程获取请求。有效负载为JSON格式,因此我想将Content-Type标头更改为application/json。我已使用以下代码执行此操作:
let email = document.getElementById("email").value
let password = document.getElementById("password").value
const body = {"email":email, "password":password}
const headers = new Headers({
"Content-Type": "application/json",
"Content-Length": JSON.stringify(body).length
})
const options = {
method: "POST",
mode: "no-cors",
headers: headers,
body: JSON.stringify(body)
}
console.log(options)
const response = await fetch('http://xx.xx.xx.xxx/login', options)
const json = await response.json()
console.log(json)
Run Code Online (Sandbox Code Playgroud)
但是,在Chrome开发者工具控制台中,Content-Type请求的标头仍为text/plain;charset=UTF-8。我究竟做错了什么?
fetch-api ×1
javascript ×1
json ×1
python ×1
python-3.x ×1
reactjs ×1
syntax ×1
syntax-error ×1