Python_图解教程

说明:本教程用图片+源码讲解Python常见的问题,共勉!

1.Python包的调用  

# coding:utf8

# from pakge.mymodel import test

from bao.pakge.mymodel import test
# 根据__init__.py检测包并存到环境变量里面,直接调用,不用管路径

mylist= [1,2,3]
a = test(mylist)
a.prt()
a.tplt()
main.py
import matplotlib.pyplot as plt
class test(object):
    num = []
    def __init__(self, _list):
        super(test, self).__init__()
        self.num = _list

    def prt(self):
        print(self.num)

    def tplt(self):
        plt.plot(self.num)
        plt.show()

# mylist= [1,2,3]
# a = test(mylist)
# a.prt()
# a.tplt()
mymodel.py

注:Python根据__init__.py判断一个文件夹是不是包;__init__.py可以为空

2.Python  

猜你喜欢

转载自www.cnblogs.com/hellangels333/p/9094714.html