- “笨辦法”學Python 3
- (美)澤德 A.肖
- 279字
- 2020-01-16 10:58:02
習題2 注釋和#號

程序里的注釋是很重要的。它們可以用自然語言告訴你某段代碼的功能是什么。想要臨時移除一段代碼時,你還可以用注釋的方式臨時禁用這段代碼。這個習題就是讓你學會如何在Python中使用注釋。
ex2.py
1 # A comment, this is so you can read your program later. 2 # Anything after the # is ignored by python. 3 4 print("I could have code like this.")# and the comment after is ignored 5 6 # You can also use a comment to "disable" or comment out code: 7 # print("This won′t run.") 8 9 print("This will run.")
從現在開始,我將用這樣的方式來演示代碼。我一直在強調“完全一樣”,不過你也不必按照字面意思理解。你的程序在屏幕上的顯示可能會有些不同,重要的是你在文本編輯器中錄入的文本的正確性。事實上,我可以用任何編輯器寫出這段程序,而且內容是完全一樣的。
推薦閱讀
- Objective-C Memory Management Essentials
- Learning Informatica PowerCenter 10.x(Second Edition)
- Mastering AndEngine Game Development
- 碼上行動:用ChatGPT學會Python編程
- 精通Linux(第2版)
- Mastering JavaScript Design Patterns(Second Edition)
- 單片機原理及應用技術
- Learning ECMAScript 6
- HTML5 Canvas核心技術:圖形、動畫與游戲開發
- Microsoft XNA 4.0 Game Development Cookbook
- 從零開始學UI設計·基礎篇
- Learning ClojureScript
- NLTK Essentials
- Balsamiq Wireframes Quickstart Guide
- Node Cookbook(Third Edition)