python基础--调用自己定义的类

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/legend818/article/details/77323676

定义一个class MyTimer,文件名mytimer,保存在指定路径 假设:D:\studypython 目录下

如果使用python shell去调用,需要

>>> import sys;
>>> sys.path.append('D:\studypython');
>>> from mytimer import MyTimer
>>> t1 = MyTimer()




如果是直接放在python安装目录下,

>>> from mytimer import MyTimer
>>> t1 = MyTimer()

猜你喜欢

转载自blog.csdn.net/legend818/article/details/77323676