我有一个段落,想将其中的特定单词加粗,复制到剪贴板以粘贴到 onenote 中。我不知道如何使粗体格式起作用。这是我到目前为止所拥有的。
LL=L.split("****")
newlist = []
for line in LL:
newline = ""
if line.strip().isnumeric():
newline = newline + '<b>' + line + '</b>'
if any(string in line for string in boldstrings):
for string in line.split(" "):
if any(word in string for word in boldstrings):
newline = newline + '<b>' + string + '</b>' + " "
else:
newline = newline + string + " "
newline = newline + "\n"
print(newline)
newlist.append(newline)
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(' '.join(newlist))
r.update() # now it stays on the clipboard after the window is closed
r.destroy()