我有四个不同的文件:main,vector,entity和physics.我不会发布所有代码,只发布导入,因为我认为这就是错误所在.(如果你愿意,我可以发布更多)
主要:
import time
from entity import Ent
from vector import Vect
#the rest just creates an entity and prints the result of movement
Run Code Online (Sandbox Code Playgroud)
实体:
from vector import Vect
from physics import Physics
class Ent:
#holds vector information and id
def tick(self, dt):
#this is where physics changes the velocity and position vectors
Run Code Online (Sandbox Code Playgroud)
向量:
from math import *
class Vect:
#holds i, j, k, and does vector math
Run Code Online (Sandbox Code Playgroud)
物理:
from entity import Ent
class Physics:
#physics class gets an entity …Run Code Online (Sandbox Code Playgroud) 这些python文件扩展名是什么意思?
它们之间有什么区别?它们是如何从*.py文件生成的?
我目前正在Django中工作,正在尝试从中导入login,django.contrib.auth.views但是出现以下错误:
ImportError: cannot import name 'login'
Run Code Online (Sandbox Code Playgroud)
这是我的urls.py:
from django.conf.urls import url
from . import views
from django.contrib.auth.views import login
urlpatterns = [
url('', views.home),
url('login', login, {'template_name': 'accounts/login.html'})
]
Run Code Online (Sandbox Code Playgroud)
错误消息(cmd):
ImportError: cannot import name 'login'
Run Code Online (Sandbox Code Playgroud)