Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python复制并粘贴word或onenote的格式化字符串_Python_String_Clipboard_Onenote_Formatted - Fatal编程技术网

python复制并粘贴word或onenote的格式化字符串

python复制并粘贴word或onenote的格式化字符串,python,string,clipboard,onenote,formatted,Python,String,Clipboard,Onenote,Formatted,我有一个段落,想加粗其中的特定单词,复制到剪贴板粘贴到onenote中。我想不出如何使用粗体格式。这是我到目前为止所拥有的 LL=L.split("****") newlist = [] for line in LL: newline = "" if line.strip().isnumeric(): newline = newline + '<b>' + line + '</b>' if

我有一个段落,想加粗其中的特定单词,复制到剪贴板粘贴到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()
LL=L.split(*****)
新列表=[]
对于LL中的行:
换行符=“”
如果line.strip().isnumeric():
换行符=换行符+“”+换行符+“”
如果有(粗体字符串的行中字符串):
对于第行中的字符串。拆分(“”):
如果有(字符串中的单词对应粗体字符串中的单词):
换行符=换行符+“”+字符串+“”+“”
其他:
换行符=换行符+字符串+“”
换行符=换行符+“\n”
打印(换行)
newlist.append(换行符)
r=Tk()
r、 撤回
r、 剪贴板_clear()
r、 剪贴板_追加(“”.join(newlist))
r、 update()#现在它在窗口关闭后保留在剪贴板上
r、 销毁

有效吗?看看答案。它打印出标记,而不是解释它。我在发布之前检查过,我无法在我的系统上安装klembord。请尝试使用unicode
'\033[1m'
而不是
'
'\033[0m'
而不是
'
。我也尝试过了。它给我[1mSTRING[0m]作为粘贴文本的输出