变量的定义:

变量第一次出现不是声明类型就是赋初值,才能后续使用。

函数的定义:

    '''

        函数的返回值不用声明类型

        函数参数值最好赋一个类型值,例如整型赋值0,列表[]

        函数名后面必须跟:

    '''

    def functionName(param=0):

        return 1

类的定义:

'''

    object后面代表父类

    类的声明最后必须以:结尾

    每个类必须有一个__init__方法,而且参数必须包含self

'''

class trainUser(object):

    """docstring for trainUser"""

    def __init__(self, userID,itermId,score,date,iterm_catertory):

        self.userID = userID

        self.itermID = itermId

        self.score = score

        self.date = date

        self.iterm_catertory = iterm_catertory

Python----定义的更多相关文章

  1. caffe中使用python定义新的层

    转载链接:http://withwsf.github.io/2016/04/14/Caffe-with-Python-Layer/ Caffe通过Boost中的Boost.Python模块来支持使用P ...

  2. python定义函数时的默认返回值

    python定义函数时,一般都会有指定返回值,如果没有显式指定返回值,那么python就会默认返回值为None, 即隐式返回语句: return None 执行如下代码 def now(): prin ...

  3. python定义的一个简单的shell函数的代码

    把写代码过程中经常用到的一些代码段做个记录,如下代码段是关于python定义的一个简单的shell函数的代码. pipe = subprocess.Popen(cmd, stdout=subproce ...

  4. Python定义点击右上角关闭按钮事件

    Python定义点击右上角关闭按钮事件(Python defines the event of clicking the close button in the upper right corner) ...

  5. python定义接口继承类

    zxq547 python定义接口继承类invalid syntax解决办法 1 2 3 4 5 6 7 class s_all(metaclass=abc.ABCMeta):     #python ...

  6. python 定义函数

    在Python中,定义一个函数要使用def语句,依次写出函数名.括号.括号中的参数和冒号:,然后,在缩进块中编写函数体,函数的返回值用return语句返回. 我们以自定义一个求绝对值的my_abs函数 ...

  7. Python定义常量

    用Python实现常量 定义 # coding=utf-8 # const.py class ConstAssignError(Exception): pass class _const(object ...

  8. python定义类()中写object和不写的区别

    这里需要说明一下: python3中,类定义默认继承object,所以写不写没有区别 但在python2中,并不是这样 所以此内容是针对python2的,当然python3默认继承,不代表我们就傻乎乎 ...

  9. Python定义函数

    在Python中,定义一个函数要使用def语句,依次写出函数名.括号.括号中的参数和冒号:,然后,在缩进块中编写函数体,函数的返回值用return语句返回. 我们以自定义一个求绝对值的my_abs函数 ...

  10. python定义函数以及参数检查

    (转自廖雪峰网站) 函数定义 在Python中,定义一个函数要使用def语句,依次写出函数名.括号.括号中的参数和冒号:,然后,在缩进块中编写函数体,函数的返回值用return语句返回. 我们以自定义 ...

随机推荐

  1. LA 小、杂、乱题合辑

    ${\Large 1.}$(来自丘维声『高等代数』(上)$P_{189,194}$) $(1).$ 设$A,B$分别是数域${\mathbb F}$上$n\times n,m\times n$矩阵. ...

  2. SQL Server T-SQL高级查询1

    高级查询在数据库中用得是最频繁的,也是应用最广泛的. Ø 基本常用查询 --select select * from student;   --all 查询所有 select all sex from ...

  3. 用于 Visual Studio 和 ASP.NET 的 Web 应用程序项目部署常见问题

    https://msdn.microsoft.com/zh-cn/library/ee942158(v=vs.110).aspx#can_i_exclude_specific_files_or_fol ...

  4. INDEX RANG SCAN无需回表的情况

    create table a3 as select * from dba_objects create index a3_idx1 on a3(owner); select owner from a3 ...

  5. topcoder13185 TreePuzzle

    https://community.topcoder.com/stat?c=problem_statement&pm=13185 被wck屠了. 考试时候想分类讨论,结果发现情况有点复杂,最后 ...

  6. CentOS 6.4 安装 Fcitx4.0

    一.首先安装中文支持: su root yum install "@Chinese Support" exit yum remove ibus 注销再登陆 二.安装fcitx 下载 ...

  7. 黑马程序员_Java基础组成

    Java语言基础组成 2.1关键字 main不是关键字,但被JVM所识别的名称. 关键字的定义和特点 定义:被Java语言赋予了特殊含义的单词. 特点:关键字中所有字母都为小写. 用于定义数据类型的关 ...

  8. cf590A Median Smoothing

    A. Median Smoothing time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  9. 下载doxygen

    官网首页:http://www.stack.nl/~dimitri/doxygen/index.html 下载页面:http://www.stack.nl/~dimitri/doxygen/downl ...

  10. Jmeter安装设置

    Linux: 其实下载之后就可以用,不过为了能在命令行直接敲入”jmeter"就可以调出Jmeter程序,还需要进行如下设置. 1. Download apache-jmeter-2.12. ...