另外需要注意一点的就是,python入门的许多示例程序都是命令行窗口执行的,就像这样:

这种简单的命令是没有问题的,但是一旦需要调用函数,就非常有可能因为缩进问题无法执行。
所以,建议初学Python使用脚本,控制台输入
python hello.py
这种方式测试函数。
# -*- coding: utf-8 -*-
'''
@Descripttion:
@Version:
@Author: neuhxy
@Date: 2019-12-07 22:03:48
@LastEditors: neuhxy
@LastEditTime: 2019-12-07 22:04:28
'''
def test():
'''
@description:
@param :
@return:
'''
print("This is test.")
if __name__ == "__main__":
test()
打印实验结果:
This is test.