turtle 模块以面向对象和面向过程的方式提供 turtle 图形基元。由于它使用Tkinter作为基础图形,因此需要安装有Tk支持的Python版本。
turtle.Screen().bgcolor()
此方法用于设置或返回Turtle屏幕的背景色。
用法:
turtle.bgcolor(*args)
参数:格式 参数 描述 bgcolor(“color”) color 颜色名称字符串 bgcolor(r, g, b) r,g,b RGB颜色代码值
下面是上述方法的实现和一些示例:
范例1:
Python3
# importing package
import turtle
# set the background color
# of the turtle screen
turtle.Screen().bgcolor("orange")
# move turtle
turtle.forward(100)
输出:
范例2:
Python3
# importing package
import turtle
# set the background color
# of the turtle screen
turtle.Screen().bgcolor(0,0,255)
# move turtle
turtle.forward(100)
输出:
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
相关用法
- Python Wand function()用法及代码示例
- Python Numbers choice()用法及代码示例
- Python Tkinter askopenfile()用法及代码示例
- Python round()用法及代码示例
- Python id()用法及代码示例
- Python Union()用法及代码示例
- Python isdisjoint()用法及代码示例
注:本文由纯净天空筛选整理自deepanshu_rustagi大神的英文原创作品 turtle.Screen().bgcolor() function in Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。