zoukankan      html  css  js  c++  java
  • 自定义函数基础

    • 语法结构

      def function_name(p):

        (tab) statement1

        (tab) statement2

        (tab) statement3

      申明函数名尾部需要“:”

      使用tab缩进区分语句结构

      函数无返回类型

    def test_a():
        print '  Hello the bling'
        print '  www.bling.com'
    print 'Entry programme'
    test_a()
    print 'Leave programme'
    
    
    #打印
    Entry programme
      Hello the bling
      www.bling.com
    Leave programme

    函数定义-形参,参数可有、可无

    # -*- coding: cp936 -*-
    def test_a():
        print '  Hello the bling'
        print '  www.bling.com'
    def test_b(p1,p2):#函数定义,形参
        print p1,
        print p2
    print 'Entry programme'
    test_a()
    test_b('yml',',jun')#函数调用,实参
    test_b(11,13)
    print 'Leave programme'
    
    #输出
    Entry programme
      Hello the bling
      www.bling.com
    yml ,jun
    11 13
    Leave programme
  • 相关阅读:
    排名第一、第二的OCR软件
    补码输出
    枚举 与 枚举的应用
    动态构造结构体数组
    c 冒泡排序
    strcpy
    typedef用法
    C 结构体小结
    int 占一个机器字长
    SQL Server创建视图——视图的作用
  • 原文地址:https://www.cnblogs.com/yangml/p/3859255.html
Copyright © 2011-2022 走看看