Day 16 – 面向对象编程(OOP)
面向对象编程(Object Oriented Programming, OOP),模拟事物为对象(Object),每个对象都有自己的属性(attribute)以及方法(methods)。 对象与类 在 OOP 中,有类(Class)以及对象(Obje...
Day 18 – Turtle 与 GUI
绘制正方形 利用turtle进行正方形的绘制 # 导入模块 import turtle for i in range(4): turtle.forward(100) turtle.left(90) my_screen = turtle.Screen() # 点击屏幕推出GUI界面 my_screen.ex...
Day 19 – 实例、状态和高级函数
事件监听 turtle模块的事件监听,通过 screen 的 listen 方法实现。 from turtle import Turtle, Screen tim = Turtle() screen = Screen() def move_forward(): tim.forward(100) # 监听屏幕输...
Day 20 – 贪吃蛇(上)
设置游戏屏幕 from turtle import Screen screen = Screen() # 设置屏幕大小 screen.setup(width=600, height=600) # 设置背景颜色 screen.bgcolor('black') # 设置标题 screen.title('贪吃蛇')...
What calls the first async function? 什么调用第一个异步函数?
You can only call async functions from other async functions, because they might need to suspend themselves and everything that is waiting for them. This leads to a bit of a chicke...
How to make parts of an actor nonisolated 如何使 actor 的各个部分非隔离
All methods and mutable properties inside an actor are isolated to that actor by default, which means they cannot be accessed directly from code that’s external to the actor. Acce...
GeometryReader
要获得视图的大小,即使不是不可能,也是很困难的。这正是 GeometryReader 可以提供帮助的地方。 GeometryReader 与推出式容器视图类似,可以添加子视图。它允许检查和使用有助于定位其中其他视...
What is a synchronous function? 什么是同步函数?
By default, all Swift functions are synchronous, but what does that mean? A synchronous function is one that executes all its work in a simple, straight line on a single threa...