Python导入模块(包)的两种方式 TypeError: 'module' object is not callable
生活随笔
收集整理的這篇文章主要介紹了
Python导入模块(包)的两种方式 TypeError: 'module' object is not callable
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
Python編程時(shí)明明在開始處import了相關(guān)包,但是調(diào)用函數(shù)時(shí)就報(bào)錯(cuò)如下:
?TypeError: 'module' object is not callable
Python中有兩種導(dǎo)入包(模塊,module)的方法,例如有個(gè)模塊叫做test,其中test中有個(gè)test函數(shù)
1、一種導(dǎo)入模塊的方法是
import test正確的使用方法是
test.test(參數(shù)列表)2、另一種導(dǎo)入模塊的方法是
from test import *
此時(shí)調(diào)用函數(shù)時(shí)不需要再加上模塊的名字了,直接使用函數(shù)名即可,如下:
test(函數(shù)列表)
總結(jié)
以上是生活随笔為你收集整理的Python导入模块(包)的两种方式 TypeError: 'module' object is not callable的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 十年学会程序设计
- 下一篇: python list列表排序的两种方法