pycharm 使用心得(八)如何调用另一文件中的函数

yipeiwu_com6年前Python基础

实现步骤:

1. PyCharm, IDE有个Project setting图标,是给run图标做配置的,配置run file为myfile.py
2.

复制代码 代码如下:

# --------------------------------------
#! /usr/bin/python
# File: myfile.py
# Author: Michael Fan


from make.py import do


def main():
do()


if __name__ == '__main__':
main()
# --------------------------------------

3.

复制代码 代码如下:

mic@ubt: ~$ ls
> make.py myfile.py

mic@ubt: ~$ ./myfile.py
> Hello, world!

相关文章

python读取txt文件中特定位置字符的方法

如下所示: # -*- coding:utf-8 -*- import sys reload(sys) sys.setdefaultencoding('utf8') fp = op...

对python中url参数编码与解码的实例详解

一、简介 在python中url,对于中文等非ascii码字符,需要进行参数的编码与解码。 二、关键代码 1、url编码 对字符串编码用urllib.parse包下的quote(stri...

Python中使用gzip模块压缩文件的简单教程

压缩数据创建gzip文件 先看一个略麻烦的做法   import StringIO,gzip content = 'Life is short.I use python'...

python的id()函数解密过程

>>> a = 2.5 >>> b = 2.5 >>> c = b >>> a is c False >&g...

Python常用库大全及简要说明

环境管理 管理 Python 版本和环境的工具 p:非常简单的交互式 python 版本管理工具。官网 pyenv:简单的 Python 版本管理工具。官网 Vex:可以在虚拟环境中...