gpt4 book ai didi

python - 连接字符串 MAKO

转载 作者:太空宇宙 更新时间:2023-11-04 06:20:11 25 4
gpt4 key购买 nike

这是我的 Mako 代码,但当我将此代码与我的服务器 Cherrypy 一起使用时出现错误。错误是

SyntaxException: (SyntaxError) invalid syntax (<unknown>, line 1) (u"c=inputp${k}_id\nsomeval= ${urld['kwargs']['${c}']}") in file '/home/user/Scaricati/prototypefin/template/web_editor_parameter_settings.html' at line: 164 char: 1

我什么时候弄错了这段代码?我必须尝试,如果有相关值并打印其内容

    <div id="sortparam" >

<%
k = 1
a=99
%>
<ul class="ui-sortable" id="sorpara">
% for k in a:
<%
c=inputp${k}_id
someval= ${urld['kwargs']['${someval}']}
%>
% if someval is UNDEFINED:
<% break %>
% else:
<li id="inputp${id}_id" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>${someval}</li>

% endif
% endfor
</ul>
</div>

啊,我想念变量 kwargs 是什么??kwargs 是我文件的内容

{'demo_title': 'Demo title', 'demo_input_description': 'hola mundo ', 'demo_params_description': '  ', 'demo_wait_description': ' ', 'demo_result_description': '  ', 'images_config_file': 'cfgmydemo.cfg', 'demo_data_filename': 'data_saved.cfg', 'tag': '', 'inputdata1_id': 'id_lsd', 'inputdata1_max_pixels': '1024000' }

我哪里错了??

最佳答案

试试这段代码:

<div id="sortparam" >

<%
k = 1
a=99
%>
<ul class="ui-sortable" id="sorpara">
% for k in a:
<%
c='inputp'+k+'_id'
%>
% if c in urld['kwargs'] :

<li id="inputp${k}_id" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>${urld['kwargs']['${c}']}</li>

% endif
% endfor
</ul>
</div>

关于python - 连接字符串 MAKO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12933922/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com