【“笨办法”学Python】2.程序的注释—— #

2.程序的注释—— #


文章目录

  • 前言
  • 一、Atom文本编辑器
  • 二、运行Python程序
  • 总结


前言

  程序的注释很重要!有两个重要的作用:
(1) 说明某段代码的作用。
(2) 临时禁用这段代码。

   # 号,英文为octothorpe或者pound character。


一、Atom文本编辑器

【“笨办法”学Python】2.程序的注释—— #_第1张图片

  注释的作用。

# A comment, this is so you can read your program later.
# Anything after the # is ignored by python.

print("I could have code like this.") # and the comment after is ignored

# You can also use a comment to "disable" or comment out code:
# print("This won't run.")

print("This will run.")


二、运行Python程序

  在Window上键入Python就可以看到结果。

python ex2.py

【“笨办法”学Python】2.程序的注释—— #_第2张图片


总结

  以上内容介绍了注释("#")的作用,有关Python、数据科学、人工智能等文章后续会不定期发布,请大家多多关注,一键三连哟(●’◡’●)。

你可能感兴趣的:(笨办法学Python,python,开发语言,后端)