html+php+python 网页显示中文乱码

问题遇到的现象和发生背景

因为不熟悉web Flask框架,所以只能用现有的php知识为我们的python程序写个前端页面,but网页中的中文会显示为乱码。

问题相关代码

这是html页面,负责传值

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <form action="NLPtest.php" method="post">
        <input type="text" name="test" id="">
        <input type="submit" value="ttt">
    </form>
</body>

</html>

这是效果图

img

这是php代码

<?php
header("Content-type:text/html;charset=utf-8");
echo ("Congratulations!\n");
$test = $_POST['test'];

$cmd = system("python test.py {$test}", $ret);

这是python代码

# -*- coding:utf-8 -*-
import sys
print(sys.argv[1])
这是运行结果

img

我的解答思路和尝试过的方法

如代码所示我已经把三个代码都改成了utf-8编码格式了,但是还是乱码。
谢谢大嘎~

文件保存时的编码不对

img