I needed a help with cgi forms in python. This code works normally when I do not enter accents:
# !/Programas/Python36-32/python
# -*- coding: utf-8 -*-
import cgi
print("Content-Type: text/html; UTF-8\n")
form = cgi.FieldStorage()
web_page="""
<!DOCTYPE HTML>
<html>
<head>
<title>O Meu primeiro programa</title>
</head>
<body>
<form method="post">
Name: <input type="text" name="name"><br>
Password: <input type="text" name="password"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
"""
print(web_page)
name=form["name"].value
password=form["password"].value
print("name: "+name)
print("<br>")
print("password: "+password)
with open("file.txt", "w") as f:
f.write("name: "+name+"\n"+"password: "+password)
But just do not write anything in the file when I put accents. Can someone help me save field data into a file?
Note: I use the XAMPP server, version 3.2.2 with apache version 2.4.29 and python version 3.6.2