Skip to content

Commit 5a1eed6

Browse files
committed
py1
1 parent 6bcb9be commit 5a1eed6

5 files changed

Lines changed: 71 additions & 0 deletions

File tree

py2/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env python
2+
# -*- coding:utf-8 -*-
3+
# Author:jiaming
4+
# Date: 2018/12/22 14:23
5+
# Describe:
6+
7+
__all__ = ['amoduledemo']

py2/amodule.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env python
2+
# -*- coding:utf-8 -*-
3+
# Author:jiaming
4+
# Date: 2018/12/22 14:24
5+
# Describe: 模块
6+
7+
from py2 import amoduledemo
8+
9+
amoduledemo.fib1(100)
10+
print(amoduledemo.fib2(100))
11+
12+
print(amoduledemo.__name__)

py2/amoduledemo.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python
2+
# -*- coding:utf-8 -*-
3+
# Author:jiaming
4+
# Date: 2018/12/22 14:27
5+
# Describe: Module Demo
6+
7+
# Fibonacci Numbers Modules
8+
9+
10+
def fib1(n):
11+
a, b = 0, 1
12+
while b < n:
13+
print(b, end=' ')
14+
a, b = b, a+b
15+
print()
16+
17+
18+
def fib2(n):
19+
result = []
20+
a, b = 0, 1
21+
while b < n:
22+
result.append(b)
23+
a, b = b, a+b
24+
return result
25+
26+

py3/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env python
2+
# -*- coding:utf-8 -*-
3+
# Author:jiaming
4+
# Date: 2018/12/22 14:55
5+
# Describe:

py3/aclass.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python
2+
# -*- coding:utf-8 -*-
3+
# Author:jiaming
4+
# Date: 2018/12/22 14:56
5+
# Describe: Class & Instance
6+
7+
8+
class Student(object):
9+
def __init__(self, name, score):
10+
self.name = name
11+
self.score = score
12+
13+
def print_score(self):
14+
print("%s: %d" % (self.name, self.score))
15+
16+
17+
print(Student)
18+
bart = Student('Jack', 30)
19+
print(bart)
20+
bart.name = 'Jason Borne'
21+
print(bart.print_score())

0 commit comments

Comments
 (0)