做动态表情包的网站,传媒网站建设方案,网站添加新闻,家政公司不是单例类#xff0c;如下#xff1a;
class StrTools():pass
str1StrTools()
str2StrTools()
print(str1)
print(str2) 运用单例#xff0c;先创建一个test.py
class StrTools():pass
str1StrTools()然后创建一个hello.py#xff0c;在这个文件中引用test.py中的对象如下
class StrTools():pass
str1StrTools()
str2StrTools()
print(str1)
print(str2) 运用单例先创建一个test.py
class StrTools():pass
str1StrTools()然后创建一个hello.py在这个文件中引用test.py中的对象如下
from test import str1
s1str1
s2str1
print(s1)
print(s2) 执行结果可以看出这两个对象是同一个对象。