Lv.1
在 【编程语言】python pip命令显示下面的报错,求解 中回复
(ImportEeeor:导入错误)当遇到无法导入某个python模块时,可能会是没有安装某个模块,也有可能是某模块在加载过程中失败,也有可能是陷入了循环导入的问题。
2022-07-26T21:42:35 点赞:0
在 贪吃蛇Python 中回复
from turtle import *
def draw_circle(size=1, x=0, y=0, r=1, c='black', v=0, fillcolour='white'):
# size参数为画笔粗细,参数x和y为坐标,参数r为圆的半径,参数c为画笔颜色,参数v为速度,参数fillcolour为填充颜色。
# 以下为主程序
print('Welcome to use draw_circle function!')
# 设置画笔粗细
pensize(size)
# 设置画笔颜色
color(c)
# 设置填充颜色
fillcolor(fillcolour)
# 设置绘画速度
speed(v)
# 移动到x, y坐标
penup()
goto(x, y)
# 开始填充
begin_fill()
pendown()
# 画圆
circle(r)
end_fill()
done()
# 调用
draw_circle(3, 0, 1, 100, 'red', 0, 'red')2023-06-28T21:33:24 点赞:0
在 贪吃蛇Python 中回复
# coding=UTF-8
import random
while True:
# 计算机随机生成1~3之间的数
a = random.randint(1, 3)
# 检测用户是否输入非1~3的其他文字,如果是,进入下一轮循环
try:
b = int(input('1-剪刀 2-石头 3-布 '))
except:
print('输入的是无效字符')
continue
print('计算机出的数字是', a)
print('我出的数字是', b)
# 检测输入的数是否大于3,小于1
if b > 3 or b< 1:
print('请输入1~3')
continue
# 计算分数
if a == b:
print('平局')
elif a==2 and b==1:
print('计算机赢')
elif a==1 and b==2:
print('玩家赢')
elif a==1 and b==3:
print('计算机赢')
elif a==3 and b==1:
print('玩家赢')
elif a==2 and b==3:
print('玩家赢')
else:
print('计算机赢')
# 是否结束
i = str(input('是否结束?y/n '))
if i == 'n':
continue
elif i == 'y':
break
# 其他结果处理
else:
print('此为无效字符')
break2023-06-28T21:33:45 点赞:0