Python的from import和import的区别?

来源:互联网 发布:无法开启网络发现 编辑:程序博客网 时间:2024/05/19 19:16
models.py
# coding=utf-8from django.db import models# Create your models here.class Product(models.Model):    productId = models.AutoField(u'产品编号', primary_key=True)    productName = models.CharField(u'产品名称', max_length=50)    productWebsite = models.CharField(u'产品网站', max_length=100)    productShelfTime = models.DateTimeField(u'产品上架时间', auto_now_add=True)    productPrice = models.FloatField(u'商品价格')

spider_main.py #使用models.py的文件
#第一种情况from spider.models import *Product.objects.get(productId = 1)#第二种情况import spider.modelsspider.models.Product.objects.get()


引用知乎大神的解释:
from import : 从车里把矿泉水拿出来,给我 import : 把车给我



 
原创粉丝点击