《笨办法学Python》 第2课手记

《笨办法学Python》 第2课手记

这节课的内容很简单,目的是要探求#号的作用,目前我们已知的内容是,作为注释的标识符。

在Python中输入如下代码并运行。

# 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 a piece of code:
#print "This won't run."

print "This will run."

结果:
这里写图片描述

只有中间两句话输出,因为其余部分在python都是注释,编译时都被忽略。

本节涉及的内容:

“#”在python中的作用:

#!/usr/bin/python

这段代码中#用来定义python解释器(编译器?)的位置。

目前只在知乎找到这么一个除了注释之外的作用,稍后再补吧。

原文地址:https://www.cnblogs.com/wanghongze95/p/13842723.html