如题所述
打印输出
不带输出项的print即为输出一个空行,如果之前的print语句输出项的最后用了诸如“,”或“;”,则表示其输出是在同一行上。其后面的空的print语句用来消除前面的print语句一直在同一行上输出的效果,使其后面的输出是在下一行。
Print()
功能
以当前字体在打开的打印作业中打印一行或多行文本。
语法Print(printjobnumber,{tab1,}string{,tab2})
例如用在编程中:
定义一个整型数组,将50个随机的两位正整数从下标1开始放入该数组中,求出该数组中具有偶数值的偶数下标元素之和,同时输出该数组中所有元素的值,每行输出10个值。
dim a(50) as integer
dim i,s as integer
randomize
s=0
for i=1 to 50
a(i)=int(rnd()*99)+1
if a(i) mod 2=0 then s=s+i
next i
print "s=";s
for i=1 to 50
print a(i);
if i mod 10=0 then print
next i
命令 PRINT (DOS命令)
打印文本文件。
PRINT [/D:device] [[drive:][path]filename[...]]
/D:device 指定打印机设备。
vb语句。
PHP打印数组命令。
Python中
示例1:
>>>print 'Hello World'
Hello World
示例2:
>>> print "%s is number %d" % ('Python', 1)
Python is number 1
>>> print "s price is f" % ('Core Python Programming', 31.25)
CorePythonProgramming price is 31.250000
Python的打印输出函数print,包括sep、end、file、flush等多个参数,他们分别有什么作用呢?请跟随大陈一起来实验吧。