问题描述
- liunx下运行python程序时出现:class: command not found
-
#!/usr/bin/python-*- coding: UTF-8 -*-
class Employee:
'所有员工的基类'
empCount = 0def init(self, name, salary):
self.name = name
self.salary = salary
Employee.empCount += 1def displayCount(self):
print "Total Employee %d" % Employee.empCountdef displayEmployee(self):
print "Name : ", self.name, ", Salary: ", self.salary"创建 Employee 类的第一个对象"
emp1 = Employee("Zara", 2000)
"创建 Employee 类的第二个对象"
emp2 = Employee("Manni", 5000)
emp1.displayEmployee()
emp2.displayEmployee()
print "Total Employee %d" % Employee.empCount
解决方案
你的python有没有安装好
解决方案二:
在python3中,print不再是关键字了,是一个内建函数,调用函数,参数要加上括号
时间: 2024-10-30 06:05:05