使用绝对位置
django的setting中
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
STATIC_ROOT = os.path.join(BASE_DIR, 'djearth/static')
在要用的地方引用
from django.conf import settings
with open(str(settings.STATIC_ROOT) + '/dae1/1.png', 'r') as file:
a = file.read()