zoukankan      html  css  js  c++  java
  • Python_函数

     Python_函数
    ————————————————————————————————2016年3月14日09:21:41————————————————————————————————

    #!/usr/bin/python
    i=5
       print i
    i=i + 1
       print i
    s='''This is a multi-line string.This is the second line.'''
       print s
    ~           
    [root@localhost bayaim]# ./var.py 
      File "./var.py", line 3
        print i
        ^
    IndentationError: unexpected indent

    报这个 就是 你 print 的“空格”要对齐,网上 瞎JB扯淡~~!


    改成:
    #!/usr/bin/python
    i=5
    print i
    i=i + 1
    print i
    s='''This is a multi-line string.This is the second line.'''
    print s
    ~        

    运行:
    [root@localhost bayaim]# ./var.py 
    5
    6
    This is a multi-line string.This is the second line.

    ———————————————————————————————————————————
    Python 变量作用域(局部变量和全局变量之分):
        你也可以在局部中增加: global 变量名 (强制变成全局变量,但是,需要你程序调用函数) 

    函数__返回值:
        调用后返回一个指定的值
        函数被调用后默认是none
        return 返回值
        return 执行后 函数终止
       区分返回值和打印

  • 相关阅读:
    spring cloud 搭建(服务)
    spring cloud 搭建(配置中心)
    spring cloud 搭建(注册中心)
    spring cloud 搭建
    skywalking 配置和使用(windows)
    jenkins 发布报错
    web 显示 pdf
    springmvc Cacheable 不设置key
    iRed邮箱使用情况
    关闭SSL服务[iRedMail]
  • 原文地址:https://www.cnblogs.com/bayaim/p/9437107.html
Copyright © 2011-2022 走看看