请教一个python问题,为什么我引用了一次,结果会重复执行2次的?
Class01.py
class Class01(object): # def __init__(self,text): # print(text) def hi(self,text): print ("%s" %(text))
__init__.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import test001.Class01 test1 = test001.Class01.Class01() test1.hi("2222222") test1.hi("aaaaaaa")
结果:
python.exe python/test001/__init__.py 2222222 aaaaaaa 2222222 aaaaaaa
正常执行的脚本不要叫__init__.py
去看 使用模块 这一个章节,
对呀,为什么?是__init.py的命名引起的?
Sign in to make a reply
启程与生活
请教一个python问题,为什么我引用了一次,结果会重复执行2次的?
Class01.py
__init__.py
结果: