我只是从本书的python崩溃课程中学习,而当我在class部分时,我创建了一个类,但是当我尝试运行它时,我的IDE(Pycharm)在def__init __(self,name,age)中说无效的语法错误:
def__init__(self, name, age):
^
SyntaxError: invalid syntax
Process finished with exit code 1
class Dog():
"""A simple attempt to model a Dog"""
def__init(self, name, age):
"""Initialize name and age attributes"""
self.name = name
self.age = age
def sit(self):
"""Simulate a dog sitting in response to command"""
print(self.name.title() + "is now sitting.")