python__00013__Python中类似C中的include方式
python__00013__类似C中的include方式
一、python的include方式 【python__00013__Python中类似C中的include方式】在C或者C++中有时候会用到#include指令包含某个文件,但是杂python中却没有这样的指令,python提供了import指令
二、代码如下
- d:\hello.py:
import osdef print_hello():
print('hello')hello_str = 'hello_str'
- e:\call.py:
import os
import sys
sys.path.append('d:')
from hello import *print_hello()
print(hello_str)
- 输出结果如下:
E:\>python call.py
hello
hello_str
推荐阅读
- python学习之|python学习之 实现QQ自动发送消息
- 逻辑回归的理解与python示例
- python自定义封装带颜色的logging模块
- 【Leetcode/Python】001-Two|【Leetcode/Python】001-Two Sum
- Python基础|Python基础 - 练习1
- Python爬虫|Python爬虫 --- 1.4 正则表达式(re库)
- Python(pathlib模块)
- python青少年编程比赛_第十一届蓝桥杯大赛青少年创意编程组比赛细则
- Python数据分析(一)(Matplotlib使用)
- Python|Python 9.20