我正在学习python并参加一项练习:
字符串.创建一个函数,该函数将返回与输入字符串类似的另一个字符串,但其大小写已反转.例如,输入"Mr. Ed"将导致"mR.DD"作为输出字符串.
我的代码是:
name = 'Mr.Ed'
name_list = []
for i in name:
if i.isupper():
name_list.append(i.lower())
elif i.islower():
name_list.append(i.upper())
else:
name_list.append(i)
print ''.join(name_list)
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来解决它?我的解决方案似乎很奇
我正在使用Jquery Datatable,其中包括列的自定义渲染.基于值,我将禁用其中的某些控件.我希望在发布后重新加载/刷新/重新绑定我的jquery数据表.我怎样才能做到这一点?
**Controller:**
[HttpPost]
public JsonResult PostAction(MyMOdel model)
{
//save changes to DB
return Json(new
{
Success = result,
});
}
public ActionResult MyAction()
//grab records from DB and return JSON
}
**View:**
@using (Ajax.BeginForm("PostAction", "ControllerName", null,
new AjaxOptions
{
UpdateTargetId = "update-message",
InsertionMode = InsertionMode.Replace,
HttpMethod = "POST",
OnSuccess = "updateSuccess"
}, new { @id = "myForm"
}
))
{
<table id="myTbl" class="display"><tr><td>col1</td></tr></table>
}
<script type="text/javascript">
var oTable = $('#myTbl').dataTable({
"sAjaxSource": "/ControllerName/MyAction",
<!-- more config -->
function updateSuccess(data, status, …Run Code Online (Sandbox Code Playgroud)