天灵灵丁灵
00.wangyou.com

个人资料

怪兽
座  |  22岁  |  火星
状态:
鲜花 
收歌 
献歌 
鸿热度:星级会员(4)
好友 2
粉丝 0

最新日记


近期访客

      
日记分类:我的首页    写日记    管理日记

我目前共有 2 篇日记

  • python

    Python functions have no explicit begin or end, and no curly braces to mark where the function code starts and stops. The only delimiter is a colon (:) and the indentation of the code itself. 

    Example 2.5. Indenting the buildConnectionString Function 

    def buildConnectionString(params):
        """Build a connection string from a dictionary of parameters.

        Returns string."""
        return ";".join(["%s=%s" % (k, v) for k, v in params.items()])Code blocks are defined by their indentation. By "code block", I mean functions, if statements, for loops, while loops, and so forth. Indenting starts a block and unindenting ends it. There are no explicit braces, brackets, or keywords. This means that whitespace is significant, and must be consistent. In this example, the function code (including the doc string) is indented four spaces. It doesn't need to be four spaces, it just needs to be consistent. The first line that is not indented is outside the function. 

    Example 2.6, “if Statements” shows an example of code indentation with if statements.
     发表于2006-01-04 12:11:04 144 人阅读 0 条评论

给我留言