您的位置:首页 > 编程语言 > Python开发

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

2016-01-02 23:03 627 查看

《笨办法学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解释器(编译器?)的位置。

目前只在知乎找到这么一个除了注释之外的作用,稍后再补吧。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: