第一个程序
视频锁定
{$ currentTime | date:'mm:ss' $}
{$ timeLeft | date:'mm:ss' $}
之前我们已经见了很多次print
了,print
作为Python中最常用的一种输出方式将print
后面的内容输出到屏幕。print
会将它后面的表达式当做字符串来输出并自动加入换行,之前我们做的都是print后面接一个表达式,但是当我们相接多个表达式时该怎么办呢?只要在表达式间加上逗号就可以了。
print "I am", 18, "years old"
有了输出,那么肯定也要有输入,Python中最简单的输入函数是raw_input()
,通过raw_input()
我们可以从键盘读入一个字符串赋值给自己定义的一个变量。
a = raw_input()
print a
此外我们还能给通过给raw_input()
一个字符串型的参数来在屏幕上输出一段提示性文字。
a = raw_input("Input something:")
好了学完了print
和raw_input()
让我们来完成第一个小程序。
在线练习
{$ activeFileHint $}