我需要从我的媒体目录访问文件,这些文件可以使用georinex读取并遍历它们,但是我似乎无法访问媒体目录,我不断收到无效的语法错误:.. media 。请帮助我。
我尝试更改根urls.py中的媒体url,但是它不起作用,坦率地说,如果我想从..media中找到更简单的方法,它将非常令人愉快。 我在媒体目录中也有几个不同的文件:观察,报告,协调,但对观察更感兴趣。
这是代码正在尝试进行测试:
{
"App Builder": {
"ID": "1",
"children": [
{
"API Builder": {
"ID": "2",
"2": [
"create an app using API Buider",
"make an application using API Builder",
"create API Builder application"
]
}
},
{
"UI": {
"ID": "3",
"children": [
{
"UI Builder": {
"ID": "4",
"4": [
"create an app using UI Buider",
"make an application using UI Builder",
"create UI Builder application"
]
}
},
{
"Template": {
"ID": "5",
"children": [
{
"Angular": {
"ID": "6",
"6": [
"create an app using Angular",
"make an application using Angular template",
"create Angular application"
]
}
},
{
"React": {
"ID": "7",
"7": [
"create an app using React",
"make an application using React template",
"create React application"
]
}
},
{
"PHP": {
"ID": "8",
"8": [
"create an app using PHP",
"make an application using PHP template",
"create PHP application"
]
}
}
],
"5": [
"create an app using Template",
"make an application using Template",
"create Template application"
]
}
}
],
"3": [
"create an app using user interface",
"make an application using UI",
"create UI application"
]
}
}
],
"1": [
"create an app",
"create app for me",
"can you create an application?"
]
}
}
我希望代码能够读取文件,然后可以实现迭代
答案 0 :(得分:0)
以下内容应在views.py中起作用:
import georinex as gr
from .models import Files
path = 'E:\\Project\\GWADSpro\\media'
def read_rinex_file(file_name):
obs = gr.load(os.path.join(path, file_name))
file.position_geodetic = obs.position_geodetic
file.save()