在python中如何从不同的文件调用函数?

2024-10-03 00:32:18 发布

您现在位置:Python中文网/ 问答频道 /正文

这些文件位于同一目录中。 这是我试图导入到其他文件中的函数:

RedInfantry = r"C:\Users\User\Desktop\a level computer science\Coursework\Week\Red team\InfantryRedV20.gif"
screen.addshape(RedInfantry)

#Red Infantry
def InfantryRed(x, y):
    turtle = Turtle()
    turtle.shape(RedInfantry)
    turtle.penup()
    turtle.goto(x, y)
    Health = 10
    Armour = 0
    Attack = 1
    Movement = 2
    Capture = True

    return turtle

这就是我试图做的:

from ImagesV4 import *
import turtle

ImagesV4.InfantryRed(200,200)
screen.update()

当我运行代码时,图像不会出现在屏幕上,也没有错误,只是一个空屏幕


Tags: 文件函数import目录屏幕redlevelscreen