PHP code:
Add 2>&1 (stdout & stderr) behind the command like so:
2>&1
$result = shell_exec('C:/Python27/python C:/xampp/htdocs/123.py ' . escapeshellarg(json_encode($data)) . ' 2>&1');