例如:
import time
from TST.Sound import *
其中,TST.Sound中也引入了time,且只引用部分time
比如:
复制代码
1
2from time import (asctime, clock, ctime, gmtime, localtime, mktime, sleep, strftime, strptime, struct_time, time)
那么,如果我们在脚本中后面有用到time的其他方法都会报错(如:time.sleep()),因为这里引用的为后面TST.Sound里面的,而非import time里面的。
解决方法:
将import time放在最后面:
from TST.Sound import *
import time
注意:所有系统方法的引用最好都放在最后
最后
以上就是兴奋玫瑰最近收集整理的关于python引用时需要注意,若多个相同的引用,则以最后一个为准的全部内容,更多相关python引用时需要注意,若多个相同内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复