[Python] The get() method on Python dicts and its "default" arg
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Python] The get() method on Python dicts and its "default" arg相关的知识,希望对你有一定的参考价值。
# The get() method on dicts # and its "default" argument name_for_userid = { 382: "Alice", 590: "Bob", 951: "Dilbert", } def greeting(userid): return "Hi %s!" % name_for_userid.get(userid, "there") >>> greeting(382) "Hi Alice!" >>> greeting(333333) "Hi there!"
以上是关于[Python] The get() method on Python dicts and its "default" arg的主要内容,如果未能解决你的问题,请参考以下文章
Jquery ajax get request to aspx web method not hit the breakpoint in the method and error is json pa
Get JSON with the jQuery getJSON Method
The "get" method should be used when the form is idempotent---正交的两个概念---
Python illustrating Downhill simplex method for minimizing the user-supplied scalar function的代码