python画圆并填充颜色

Python021

python画圆并填充颜色,第1张

import turtle#导入turtle库(提供基本绘图功能)

#turtle.screensize(300,300)画布大小可设置可不设

turtle.pensize(8)#设置画笔大小为8

turtle.color('red')

turtle.penup()

#turtle.goto(50,150)

turtle.pendown()

turtle.begin_fill()#开始填充

turtle.circle(50)

turtle.end_fill()#结束填充

insert()是Python中的内置函数,可将给定元素插入列表中的给定索引。

python的insert函数中有两个必填参数,第一个是填充的位置,第二个是填充的内容。必须有小数点,不然报错。一般用1.0,就是往下面一行行的写。

insert()的参数和返回值

参数:index - the index at which the element has to be inserted.

element - the element to be inserted in the list.

返回值:This method does not return any value but

it inserts the given element at the given index.

基础设置

连接cad

from pyautocad import Autocad

acad = Autocad(create_if_not_exists=True)

# 连接正在运行的CAD程序;

# CAD文件采用默认名称Drawing1。

acad.prompt("Hello! Autocad from Python.")

# 在CAD命令行显示"Hello! Autocad from Python.",用于测试对CAD的控制是否成功;

# 此时,注意观察命令行,若无反应可按F2,查看命令输入历史。

# 获得与Python连接的正在运行的CAD文件名