2

问题:粘贴后 HTML 表单不保留换行符。

我正在开发一个执行 JSON 格式验证检查的应用程序。我想将 JSON 字符串粘贴到表单中,然后让应用程序使用 Python 中的 json 模块检查其有效性。

如果有任何错误,函数:

json.loads(jsonstring)

返回发生错误的行和列。我需要检索线路和号码。但是,以我的形式粘贴不会保留换行符,因此所有内容都在第 1 行...

我该怎么做才能使表格中的粘贴保持换行符?

4

1 回答 1

0

该问题的答案是在 textarea 标记中指定选项“wrap=soft”。这给出了以下内容:

<textarea "wrap=soft">
This is the text that I pasted after I copied the output of my JSON validation function. \n 
with newlines characters that are gonna be seen after I pasted it in the text field.
</textarea>
于 2012-09-18T23:29:32.917 回答