Python(Launching unittests with arguments python -m unittest 解决)

在今天的练习过程中遇到的问题

C:\Users\hw\AppData\Local\Programs\Python\Python36\python.exe "D:\PyCharm 2017.1.5\helpers\pycharm\_jb_unittest_runner.py" --path E:/Python学习/7.24.py
Testing started at 19:05 ...
Launching unittests with arguments python -m unittest E:/Python学习/7.24.py in E:\Python学习
Ran 1 test in 0.003s

FAILED (errors=1)

Process finished with exit code 1

代码如下

def test1():
    print("hello word")
def test2():
    print("hello python")
test1()

代码并没有出现问题,但是运行却出现问题
最后总结:原因是test为关键字,不能出现在函数名或文件名中,应避免在函数及文件命名中使用。

猜你喜欢

转载自blog.csdn.net/weixin_44024993/article/details/107567954