新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:python看類里有哪些方法
Python使用 class 語句來創(chuàng)建一個新類,class 之后為類的名稱并以冒號結(jié)尾:

成都創(chuàng)新互聯(lián)公司專注于魚臺企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站設(shè)計,商城建設(shè)。魚臺網(wǎng)站建設(shè)公司,為魚臺等地區(qū)提供建站服務(wù)。全流程定制網(wǎng)站設(shè)計,專業(yè)設(shè)計,全程項目跟蹤,成都創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務(wù)
class ClassName: '類的幫助信息' #類文檔字符串 class_suite #類體
實例
class Employee: '所有員工的基類' empCount = 0 def __init__(self, name, salary): self.name = name self.salary = salary Employee.empCount += 1 def displayCount(self): print "Total Employee %d" % Employee.empCount def displayEmployee(self): print "Name : ", self.name, ", Salary: ", self.salary
通常,類中的函數(shù)被稱為方法,查看類中有幾個函數(shù),就能確定有幾個方法。
推薦學(xué)習(xí)《Python教程》。
網(wǎng)頁題目:創(chuàng)新互聯(lián)Python教程:python看類里有哪些方法
標題URL:http://fisionsoft.com.cn/article/djogeoi.html


咨詢
建站咨詢
