I'm trying to parse data with json format from php to python vice versa. php

$alternative_val = array(
    array(1, 0.5, 3),
    array(2, 1, 4),
    array(0.333, 0.25, 1)
  );
  $json = json_encode($alternative_val);
  $output = shell_exec('python spk.py "'.$json.'"');
  echo $output;

Python

php = sys.argv[1]
print(php)
# 3x3 matrix
X = [[1,0.5,3],
    [2 ,1,4],
    [0.333 ,0.25,1]]
# result is 3x4
result = [[0,0,0],
         [0,0,0],
         [0,0,0]]

# iterate through rows of X
for i in range(len(php)):
   # iterate through columns of Y
   for j in range(len(php[0])):
       # iterate through rows of Y
       for k in range(len(php)):
           result[i][j] += php[i][k] * php[k][j]

for r in result:
   print(r)

when I print(php) it look different from how it's supposed to (Python X) and when I change the X variable on for it just don't work

print(php) from python

[[1,0.5,3],[2,1,4],[0.333000000000000018207657603852567262947559356689453125,0.25,1]] 

print(X) from python

[[1, 0.5, 3], [2, 1, 4], [0.333, 0.25, 1]] 

0 Answers