我正在处理的 docx 文件有一个带有注释的超链接。
例如:https: //www.someurl.com/ddoai9101? %20dsadoi -包含学生地址的文件
https://www.someurl.com/ddoai9101?%2a1231w1 -包含学生成绩的文件
我正在尝试提取 Excel 工作表中的超链接和注释。我正在使用 python-docx 库来提取超链接和文本。但是,python-docx 库将为您提供文本或超链接。这就是我获得超链接的方式:
from docx import Document
from docx.opc.constants import RELATIONSHIP_TYPE as RT
document = Document("StudentData.docx")
rels = document.part.rels
for rel in rels:
if rels[rel].reltype == RT.HYPERLINK:
url = rels[rel]._target
Run Code Online (Sandbox Code Playgroud)
这就是我得到文本的方式
texts = document.paragraphs
for t in texts:
print(t.text)
Run Code Online (Sandbox Code Playgroud)
现在的问题是文本不显示超链接,我不知道哪个评论与哪个超链接相关联。有没有办法使用 python 从 docx 文件中获取带有超链接的文本?
我用命令安装了 httprepl
dotnet tool install -g Microsoft.dotnet-httprepl
Run Code Online (Sandbox Code Playgroud)
httprepl 被列为带有命令的已安装包
dotnet tool list -g
Package Id Version Commands
----------------------------------------------------
microsoft.dotnet-httprepl 5.0.2 httprepl
Run Code Online (Sandbox Code Playgroud)
但是当我运行命令 httprepl 时,它说找不到命令。
httprepl
zsh: command not found: httprepl
Run Code Online (Sandbox Code Playgroud)
如何在 Mac 上运行 httprepl?