复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26项目模块化: from your_file import function_name, class_name 的方式调用 node2:/root/python3/20200814#cat utils.py def get_sum(a, b): return a + b node2:/root/python3/20200814#cat class_utils.py class Encoder(object): def encode(self, s): return s[::-1] class Decoder(object): def decode(self, s): return ''.join(reversed(list(s))) node2:/root/python3/20200814#cat main.py # main.py from utils import get_sum from class_utils import * print(get_sum(1, 2)) encoder = Encoder() decoder = Decoder() print(encoder.encode('abcde')) print(decoder.decode('edcba')) node2:/root/python3/20200814#python main.py 3 edcba abcde
最后
以上就是可耐过客最近收集整理的关于python 所有文件堆在一个目录下的全部内容,更多相关python内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复