所以我觉得我已经接近尾声了,我现在必须添加这个系列.正如你所看到的,我有两个底部,它说搜索电影和搜索系列
这意味着我已经让电影工作得很好,现在我离开了这个系列.现在的问题是我真的不知道怎么做,所以Javascript知道系列按钮是打开的,然后它应该采用我的API并按原样提供信息.我已经完成了我的电影JS,就像这样:
function callAjax(input)
{
var url = "http://localhost:1337/search/" + input;
$.ajax({
type:'GET',
url: url,
success: function(data){
if(data) {
console.log('SUCCESS');
$('#title').html("Title: " + data.title);
$('#release').html("Release: " + data.release);
$('#vote').html("Vote: " + data.vote);
$('#overview').html("Overview: " + data.overview);
$('#poster').html('<img src="' + data.poster + '" width=250 height=450 />');
$('#trailer').html("Trailer: <iframe width='420' height='315' src='https://www.youtube.com/embed/" + data.trailer + "' frameborder='0' allowfullscreen>");
$("#lblerror").addClass("hide");
} else {
$("#lblerror").text("No movies were found!");
$("#lblerror").removeClass("hide");
}
},
error: function(request, status, err){
console.log('ERROR');
}
});
}
$(document).ready(function(){
$('#submitButton').on('click', function(e){
e.preventDefault();
var …Run Code Online (Sandbox Code Playgroud) profile.json我已经在与我的文件夹相同的文件夹中创建了一个文件script/.py。它看起来像:
{
"name": "",
"lastname": "",
"age": "",
"city": "",
}
Run Code Online (Sandbox Code Playgroud)
我希望将其插入到我的脚本中,该脚本的标题为:
"info": {
"given_name": "",
"given_Lastname": "",
"given_age": "",
"given_city": ""
}
Run Code Online (Sandbox Code Playgroud)
我想知道如何才能从我的profile.json脚本中读取内容?这是我第一次使用它,而且我也是 Python 新手。我觉得这可能是一种修改信息的简单方法,而不必每次都更改代码。
编辑:
尝试这样做:
with open('profile.json',encoding='UTF-8') as json_data: config = json.load(json_data) print(config)
然后:
"info":
{
"given_name": config.given_name
}
Run Code Online (Sandbox Code Playgroud)
打印内容显示了很好的信息,但是当涉及到“given_name”时:config.given_name然后我收到一条错误消息
AttributeError: 'dict' object has no attribute 'given_name'
我的愿望是使每个字符或每行或任何您认为可能看起来最适合ASCII的东西。基本上我已经尝试过,colorma并且它仅基于一种颜色。所以我在这里,问你们最好的方法是什么。我有的是
print("""
_____ _ _ __ _
/ ____| | | | / _| |
| (___ | |_ __ _ ___| | _______ _____ _ __| |_| | _____ __
\___ \| __/ _` |/ __| |/ / _ \ \ / / _ \ '__| _| |/ _ \ \ /\ / /
____) | || (_| | (__| < (_) \ V / __/ | | | | | (_) \ V V /
|_____/ …Run Code Online (Sandbox Code Playgroud)