【Python】基础-自定义模块
本文最后更新于 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]
运行结果:

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇