Python

it2022-05-05  123

1、mymodel.py

1 #!/usr/bin/python 2 3 #Filename:mymode.py 4 5 version = '1.0' 6 7 def sayHello(): 8 9 print("Hello world") 10 11 12 13 def modelName(): 14 15 return __name__ 16 17 #end of model View Code

2、test.py

1 #!/usr/bin/python 2 3 import mymodel 4 5 print(__name__) 6 7 mymodel.sayHello() 8 9 print('Version: ', mymodel.version) 10 11 print('Model Name: ', mymodel.modelName()) View Code

3、结果

1 >>> ================================ RESTART ================================ 2 >>> 3 __main__ 4 Hello world 5 Version: 1.0 6 Model Name: mymodel 7 >>> View Code

 

转载于:https://www.cnblogs.com/yml6/p/6182482.html


最新回复(0)