Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Python中运行/测试文件?_Python_Pycharm - Fatal编程技术网

如何在Python中运行/测试文件?

如何在Python中运行/测试文件?,python,pycharm,Python,Pycharm,让我首先声明,我对Python非常陌生 我有一个要完成的.py文件作为作业,但我不知道如何运行它。该文件包含: def some_func(filename): .... .... .... def main(): .... .... .... if __name__ == '__main__': main() 我正在使用PyCharm,如何运行此脚本?我想测试我的代码。我尝试通过右键单击文件并选择Run myfile.py来运行它,这

让我首先声明,我对Python非常陌生

我有一个要完成的.py文件作为作业,但我不知道如何运行它。该文件包含:

def some_func(filename):
    ....
    ....
    ....

def main():
    ....
    ....
    ....
if __name__ == '__main__':
    main()
我正在使用PyCharm,如何运行此脚本?我想测试我的代码。我尝试通过右键单击文件并选择Run myfile.py来运行它,这是我过去的做法,但我不知道如何使用此文件。

从命令行: 从PyCharm开始假设你已经 第一次:

运行->运行。。。或alt+ctrl+R 选择文件名 以后的时间:

运行->运行或按绿色播放按钮或ctrl+R
python /path/to/file/to/run.py