因为不熟悉web Flask框架,所以只能用现有的php知识为我们的python程序写个前端页面,but网页中的中文会显示为乱码。
<!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>
<?php
header("Content-type:text/html;charset=utf-8");
echo ("Congratulations!\n");
$test = $_POST['test'];
$cmd = system("python test.py {$test}", $ret);
# -*- coding:utf-8 -*-
import sys
print(sys.argv[1])
如代码所示我已经把三个代码都改成了utf-8编码格式了,但是还是乱码。
谢谢大嘎~
文件保存时的编码不对