python学习记录——导入库

假如有脚本 test1.py

def get():
    return 'this is test1'

在脚本 test2.py 中调用 test1.py 的 get 方法

1.用全名访问

import test1
print(test1.get())

2.用别名访问

import test1 as t1
print(t1.get())

3.导入全部

from test1 import *
print(get())

 

posted @ 2022-07-28 15:31  Bridgebug  阅读(88)  评论(0编辑  收藏  举报