Commit dbe9bd4c by BellCodeEditor

auto save

parent 7b9a1090
Showing with 41 additions and 26 deletions
import turtle
p = turtle.Pen()
p.fillcolor("red")
p.shape("turtle")
# p.shapesize(10)
p.begin_fill()
for i in range(5):
p.forward(100)
p.left(144)
p.end_fill()
p.hideturtle()
turtle.done()
\ No newline at end of file
# name = "悟空"
# word = "欢迎你"
# print(name+word)
# a=1
# b=1.0
# c=[1,2,3]
# d="你好"
# print(type(a))
# print(type(b))
# print(type(c))
# print(type(d))
#创建一个类
class 类名():
def __init__(self):
self.变量1 = 属性1
self.变量2 = 属性2
实例化对象
查看对象属性的时候,注意点记法
二:
实例属性
在类里面是实例方法的时候
class 类名():
def 方法名(self,形参1,形参2):
self.变量1 = 形参1
self.变量2 = 形参2
实例化对象:
实例化对象1 = 类名(实参1,实参2
实例化对象1 = 类名(实参1,实参2
查看对象属性的时候,注意点记法
实例属性
class 类名():
def __init__(self,形参1,形参2):
self.变量1 = 形参1
self.变量2 = 形参2
实例化对象:
实例化对象1 = 类名(实参1,实参2
实例化对象1 = 类名(实参1,实参2
查看对象属性的时候,注意点记法
#创建英雄类
class Hero():
def __init__(self):
self.level = 1
self.hp = 300
self.attack = 20
#实例化英雄亚瑟
yase = Hero()
print(yase.hp)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment