Я пытаюсь импортировать скрипт python (graphics.py) в другой скрипт (game.py), однако он не работает.Импорт скриптов python не работает
В game.py:
import pygame
import graphics.py
import sys # Mainly for sys.quit
"""********Start variables********"""
# Some colour constants
BLACK = ( 0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = ( 0, 255, 0)
BLUE = ( 0, 0, 255)
# Display settings
FPS = 60
fpsClock = pygame.time.Clock()
def main():
pygame.init()
# Load graphics
gfx = graphics()
И в graphics.py:
import pygame
class graphics(object):
# Create a surface that will hold the player sprite
SprPlayer = pygame.Surface((32, 32))
# At the beggining of the object, load the sprites
def __init__():
SprPlayer = pygame.image.load("Graphics\Player.png")
Так что я делаю свою первую игру питон (Python мой новый любимый язык, кроме GML.), и я не могу иметь все в одном файле. Здесь ошибка
import graphics.py
ImportError: No module named py
У меня есть оба сценария в том же каталоге, так что я не знаю, что происходит. Любая помощь приветствуется.
В какой части учебного пособия вам предлагается импортировать модули таким образом? –