def main () -> None 有什么作用?
What does def main () -> None do?
我正在学习 Mastering Matplotlib,在第二章中他们介绍了以下代码片段:
#! /usr/bin/env python3.4
import matplotlib.pyplot as plt
def main () -> None:
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.savefig('simple-line.png')
if __name__ == '__main__':
main()
这个可以在thisnotebook, cell 10中看到。我从来没有见过这样定义的main方法,-> None
的功能是什么?
到目前为止我唯一的想法是这可能类似于 def main(argv=None)
?
除此之外,Python中的->
是什么?我在 Python 运算符的 this 列表中找不到它。
我正在学习 Mastering Matplotlib,在第二章中他们介绍了以下代码片段:
#! /usr/bin/env python3.4
import matplotlib.pyplot as plt
def main () -> None:
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.savefig('simple-line.png')
if __name__ == '__main__':
main()
这个可以在thisnotebook, cell 10中看到。我从来没有见过这样定义的main方法,-> None
的功能是什么?
到目前为止我唯一的想法是这可能类似于 def main(argv=None)
?
除此之外,Python中的->
是什么?我在 Python 运算符的 this 列表中找不到它。