Python使用';用于'的url#u;
我正试图从位于Python使用';用于'的url#u;,python,flask,Python,Flask,我正试图从位于/var/www/Project/abc/static/assets/images/abc 我正在使用url\u作为函数来访问a.jpg 我的b.py文件位于/var/www/Project/ABC/ccc/b.py 如何在此处使用url\u作为功能 我尝试过使用('static',filename='assets/images/abc'+a.jpg')的imageFile=url\u 但这不会得到a.jpg文件 有人能帮忙吗?它没有得到a.jpg,因为它缺少路径分隔符 image
/var/www/Project/abc/static/assets/images/abc
我正在使用url\u作为
函数来访问a.jpg
我的b.py
文件位于/var/www/Project/ABC/ccc/b.py
如何在此处使用url\u作为功能
我尝试过使用('static',filename='assets/images/abc'+a.jpg')的imageFile=url\u
但这不会得到a.jpg
文件
有人能帮忙吗?它没有得到a.jpg
,因为它缺少路径分隔符
imageFile = url_for('static', filename='assets/images/abc' + 'a.jpg')
上述语句的右侧将计算为
imageFile = url_for('static', filename='assets/images/abca.jpg')
导入并使用它连接文件名路径
from os import path
imageFile = url_for('static', filename=path.join('assets', 'images', 'abc', 'a.jpg'))
尝试将文件名更改为:'static/assets/images/abc'+str(a.jpg)