本文最后更新于 1502 天前,其中的信息可能已经有所发展或是发生改变。
[success]
感觉这个和java的调用别的类有些相似,学习基础的时候记录下来。
[/success]
[sourcecode language=”python” title=”demo2.py”]
#demo2.py
def fib(n):
a, b =0, 1
while b<n:
print(b, end= ‘ ‘)
a, b = b, a+b
print()
def fib2(n):
result = []
a, b = 0, 1
while b<n:
result.append(b)
a, b = b, a+b
return result
def add(a,b):
return a+b
[/sourcecode]
[sourcecode language=”python” title=”text.py”]
# text.py
import demo2
demo2.fib(1000)
number = demo2.fib2(100)
number2 = demo2.add(1,3)
conten = dir(demo2)
print(number)
print(number2)
print(conten)
[/sourcecode]
运行结果: