Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/359.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使用';用于'的url#u;_Python_Flask - Fatal编程技术网

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)