flask-----No such file or directory绝对路径与相对路径
No such file or directory: '\\uploads\\03.jpeg'
相对路径:加点,或者直接绝对路径(尽量使用绝对路径,通过python的os模块获取当前文件绝对路径)
os.path.dirname(os.path.abspath(__file__)) 返回的是文件的目录
os.path.abspath(__file__)返回的是.py文件的绝对路径,包含文件名,并且返回path规范化的绝对路径
相对路径
../表示源文件所在目录的上一级目录,../../表示源文件所在目录的上上级目录,以此类推。
同级目录直接文件名可以直接引用
./下一级目录
来自stackoverflow
Both /tmp and /static/uploads/.., are absolute paths. And your code is looking in the / folder instead of looking in your project's folder. You should use the absolute path to point at your folder /path/to/your/project/static/uploads/.. or use a path relative to the code being executed such as ./static/uploads.
You can also use the following snippet to generate the absolute path:
from os.path import join, dirname, realpath
UPLOADS_PATH = join(dirname(realpath(__file__)), 'static/uploads/..')
flask-----No such file or directory绝对路径与相对路径的更多相关文章
- 无后缀名伪静态路径在IIS7.0的网站提示 "404 - File or directory not found"
新配置服务器(windows server 2008,not sp1) 经测试情况如下: ①无后缀名伪静态路径行在IIS7.0的网站提示 ”404 - File or directory not fo ...
- STM32 关于头文件路径没添加错误问题(cannot open source input file "spi.h": No such file or directory)
error: #5: cannot open source input file "spi.h": No such file or directory 1.出现这种问题,首先要确 ...
- R中读取文件,找不到路径问题 No such file or directory
R中读取文件,找不到路径问题 No such file or directory 近日,读取文件时.出现例如以下问题 > passenger = read.csv('internationa ...
- Git异常:fatal: could not create work tree dir 'XXX': No such file or directory
GitHub实战系列汇总:http://www.cnblogs.com/dunitian/p/5038719.html ———————————————————————————————————————— ...
- Warning: mysql_connect(): No such file or directory 解决方案总结(操作系统: Mac)
说明: 本文主要内容参考: Mac下PHP连接MySQL报错"No such file or directory"的解决办法, 并进行个人补充 1. 运行环境: Mac OS X 10.11.4 (M ...
- error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
zabbix3.2启动有如下报错: # service zabbix_server startStarting zabbix_server: /home/zabbix-server/sbin/zab ...
- RHEL 5.7 Yum配置本地源[Errno 2] No such file or directory
在Red Hat Enterprise Linux Server release 5.7 上配置YUM本地源时,遇到了"Errno 5] OSError: [Errno 2] No such ...
- 问题解决:psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
错误提示: psql: could not connect to server: No such file or directory Is the server running locally and ...
- 执行Python "/bin/usr/python: bad interpreter: No such file or directory" 错误
今天在电脑上写了一个Python脚本,写好之后用ftp传上去,然后执行/var/www/cron.py,结果报错,/bin/usr/python: bad interpreter: No such f ...
随机推荐
- Debian7 apt源设置
刚装完系统时是没有 apt-spy 的,这时候我们可以暂时先找个可用的源代替,如(写在 /etc/apt/sources.list 中): deb http://http.us.debian.org/ ...
- python ConfigParser 读取配置文件
- 10-21C#基础--集合
二.集合 //定义一个集合,集合是一个类, 1. 定义: ArrayList al = new ArrayList(); 2.添加数据:al.add();//添加数值,可以添加无数个元素,集合中没有 ...
- leetcode633
用开方的思想来解题. bool judgeSquareSum(int c) { int h = pow(c, 0.5); ; i <= h; i++) { ), 0.5); if (left - ...
- HADOOP HDFS BALANCER介绍及经验总结(转)
1.集群执行balancer命令,依旧不平衡的原因是什么?该如何解决? 2.尽量不在NameNode上执行start-balancer.sh的原因是什么? 集群平衡介绍 Hadoop的HDFS集群非常 ...
- 剑指offer 34_丑数
丑数:只有2 3 5 这三个因子的数,求前(第)1500个.习惯上我们把1当作第一个丑数 例如 6, 8是丑数.14不是. #include <stdio.h> int Min(int x ...
- 理解configure,make,make install(笔记整理)
在Linux系统里有时候需要自己编译安装一些提供了源文件的软件,比如Nginx.一般编译的步骤是:configure -> make -> make install. 1. configu ...
- sqlplus--sqlldr命令参数详解
sqlplus--sqlldr参数详解 sqlldr,Oracle快速导入数据的工具,是sqlplus的指令,不是sql语法里的东西. 一.下面是SQL*LOADER的基本特点:1)能装入不同数据类型 ...
- 利用脚本,一键设置java环境变量(默认安装路径)
Windows一键设置Java环境变量 右击以管理员方式运行,注意自行更改JAVA_HOME目录文件安装目录. JDKSetting.bat @echo off color 0a echo.----- ...
- iOS 通过接受距离传感器的消息改变屏幕的明暗度(仅限用于真实的手机)
#import "AppDelegate.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL ...