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时MySQLdb报错的问题描述及解决方法

问题描述: windows安装python mysqldb时报错python version 2.7 required,which was not found in the regist...

python3实现字符串操作的实例代码

python3字符串操作 x = 'abc' y = 'defgh' print(x + y) #x+y print(x * 3) #x*n print(x...

Python中动态创建类实例的方法

简介 在Java中我们可以通过反射来根据类名创建类实例,那么在Python我们怎么实现类似功能呢? 其实在Python有一个builtin函数import,我们可以使用这个函数来在运行时...

TensorFlow中权重的随机初始化的方法

一开始没看懂stddev是什么参数,找了一下,在tensorflow/python/ops里有random_ops,其中是这么写的: def random_normal(shape,...

Python类的继承用法示例

本文实例讲述了Python类的继承用法。分享给大家供大家参考,具体如下: python —类的继承 root@kali:~/python/mod# vi class2.py root...