current position:Home>HTML + PHP + Python web page displays Chinese garbled code

HTML + PHP + Python web page displays Chinese garbled code

2022-02-02 21:48:29 CSDN Q & A

The phenomenon and background of the problem

Because I'm not familiar web Flask frame , So we can only use the existing php Knowledge for us python The program writes a front-end page ,but The Chinese in the web page will be displayed as garbled .

This is a html page , Responsible for value transfer

<!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>

This is the renderings

img

This is a php Code

<?phpheader("Content-type:text/html;charset=utf-8");echo ("Congratulations!\n");$test = $_POST['test'];$cmd = system("python test.py {$test}", $ret);

This is a python Code

# -*- coding:utf-8 -*-import sysprint(sys.argv[1])
This is the result of the operation

img

My solution ideas and tried methods

As shown in the code, I have changed all three codes to utf-8 The encoding format is , But it's still garbled .
Thank you, daga ~




Refer to the answer 1:

Wrong code when saving the file

img




Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202022148269736.html

Random recommended