在 Bottle 框架的 'Yield' 中包含 html 锚标签

Including html anchor tags in the 'Yield' of the Bottle framework

最近在 python 中使用 Bottle 框架。

我正在尝试将 link 的锚标记包含到 bottle 框架的 'Yield' 组件中的本地文件夹中。

当我尝试在 Yield 语句中包含锚标记时,我总是收到错误消息

代码片段如下:

 from bottle import Bottle,run

 app = Bottle()

 @app.route('/conn')
 def conn():
     yield '<center> <p>Here is the <a href="file:///C:\Programs\Documents">Connection Folder </a>  </p> </center>'

上面的代码不是运行,我得到一个错误说'SyntaxError'。我希望得到一个结果,即在连接时初始网页产生一个新网页,其中包含语句 'Here is the connection folder' (其中字符串连接文件夹是 link 到本地文件夹)

编辑 1: 我现在已经通过这样做获得了代码:

 from bottle import Bottle,run

 app = Bottle()

 @app.route('/conn')
 def conn():
     yield '<center> <p>Here is the <a href="file:///C:\Programs\Documents">Connection Folder </a>  </p> </center>'

也就是加双斜杠

现在我的问题是 link 没有打开所需的文件夹,我应该在上面的代码中添加什么吗?

我终于找到了问题的答案:

1) SyntaxError 的错误是通过执行以下两个操作之一来排序的: 使用双反斜杠或单正斜杠都可以。

2) 然后我遇到了另一个挑战,由于 Chrome 的安全设置,link 无法访问本地文件夹。

我通过查看这个 post 解决了这个问题:Open local folder from link