Python:创建html输出时保存格式

2024-05-13 06:36:29 发布

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

我正在运行像ipconfig这样的windows命令,并试图在html页面中捕获它们。我遇到了一个问题,格式不是我想要的。我有一个写html的函数

def writeHTML(toWrite):
    output.write("<p>")
    if toWrite.find("   ") == 1:
        toWrite.replace("   ", "&nbsp")
    output.write(toWrite)
    print(toWrite)
    output.write("</p>")

我曾试图“找到”T和空白,但FoMATTACT不起作用。

首选输出:

enter image description here

电流输出:

enter image description here

如何维护格式


Tags: 函数命令outputifwindowsdefhtml格式