后浪云Python教程:python如何调用函数库

后浪云Python教程:python如何调用函数库插图

python函数库引用的第一种方式

格式是: import<库名>

例如:

import turtle

如果需要用到函数库中函数,需要使用: <库名>.<函数名>

例如:

import turtle
    turtle.fd(100)

相关推荐:《Python基础教程》

python对函数库引用的第二种方式

格式是: from<库名>import<函数名> 

from<库名>import *

调用函数不需要<库名>,直接使用<函数名>

例如:

from turtle import * 
    fd(100)
THE END