练习:
1.将以下内容输入到编辑器中,命名为ex1.py ,然后在命令行终端通过输入python ex1.py来运行这段代码:


由于使用的是python3,输入以上内容运行的时候报错了,因为python3中,print后面需要加上(),如print (“Hello World!”)


2. 附加题:让你的脚本多打印一行
通过print ("\n")实现

3.附加题:让你的脚本只打印一行
加入end = “”实现,如print (“Hello World!”,end = “”),python2中可在每一行后面加入逗号,来实现


4.附加题:在某行的起始位置放一个#符号。
#符号主要起注释作用,运行以后被注释的内容不显示,如果要注释多行,则每一行都要加#


此章节内容主要了解了print的用法,并且明白了python2和python3上面格式的差别
网友评论