Python Unescape特殊字符

2024-05-14 19:10:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个来自HTML的表单,我有python flask作为后端

我想问一下是否有办法确保&将被发送回后端,而不是**&;amp;**

假设我有3个字段。即使是通过循环,也要逐个检查它们

这是前端


<head>
    <meta charset="UTF-8">
</head>

<div class="form-group row">
    <label class="col-sm-2 col-form-label text-right">ID Stasiun</label>
    <div class="col-sm-8">
        <input type="text" class="form-control" placeholder="ID Stasiun . . ." name="id_stasiun">
    </div>
</div>

<div class="form-group row">
    <label class="col-sm-2 col-form-label text-right">Nama Stasiun</label>
    <div class="col-sm-8">
        <input type="text" class="form-control" placeholder="Nama Stasiun . . ." name="nama_stasiun">
    </div>
</div>

<div class="form-group row">
    <label class="col-sm-2 col-form-label text-right">Alamat Stasiun</label>
    <div class="col-sm-8">
        <input type="text" class="form-control" placeholder="Alamat Stasiun . . ." name="alamat_stasiun">
    </div>
</div>

现在这是我在后台做的事情

import re
from xml.sax            import saxutils as su

x = "&amp;"
su.unescape(x)
'&'

有没有办法确保我得到&;而不是检查每个字段?多谢各位


Tags: textrightdivforminputtypegroupcol

热门问题