如果我手动发送第二个请求,它可以正常工作,但是如果我尝试通过python执行此操作,它将失败。apache 日志中没有错误。文件保持不变,不会被覆盖。法典:
def fen_actions(mode,fen):
global url
if mode: # 1-> Read 2-> Write
params = {'mode':'readFen'}
else:
params = {'mode':'putFen','fen':fen}
r = requests.get(url,params)
return r.text
fen_actions(2,chess.STARTING_BOARD_FEN) #This is not working. Starting fen is just a string
temp_readed_fen = fen_actions(1,0) # This works
代码:
<?php
$f = fopen("tempfen.txt","r+") or die("Unable to open a file");
if (strval($_GET["mode"]) === strval("putFen"))
{
if(strval($_GET['fen']) != strval(fread($f,filesize("tempfen.txt"))))
{
file_put_contents("tempfen.txt","");
fwrite($f,$_GET['fen']);
}
}
else if ($_GET["mode"] === strval("readFen"))
{
echo(fread($f,filesize("tempfen.txt")));
}
ini_set('display_errors',1);
?>
小怪兽爱吃肉
相关分类