python的print函式輸出9 9乘法表

2021-10-03 23:38:18 字數 831 閱讀 9494

print:列印標準輸出的函式

格式:print()

print()函式有三個引數

value使用者需要輸出的資訊

sep多個要輸出資訊之間的分隔符,預設是空格

end輸出資訊結尾處的預設新增的符號,預設為換行符

print(*objects, sep=' ', end='\n', file=sys.stdout, flush=false)

列印99乘法表:

result=[0]*10

for i in range(1,10):

for j in range(1,10):

result[j] = i*j

for x in range(1,10):

print("%4d"%result[x],end="")

print()

輸出:1   2   3   4   5   6   7   8   9

2   4   6   8  10  12  14  16  18

3   6   9  12  15  18  21  24  27

4   8  12  16  20  24  28  32  36

5  10  15  20  25  30  35  40  45

6  12  18  24  30  36  42  48  54

7  14  21  28  35  42  49  56  63

8  16  24  32  40  48  56  64  72

9  18  27  36  45  54  63  72  81

python基礎 print 函式

深入print,在python2.x中,print是乙個語句,但是在python 3.x中,它是乙個函式。知道如何運用print函式可以幫助我們減少很多 以達到需要的輸出要求。不使用關鍵字引數 print可以列印任意數量的值 print age age age 18兩個值之間有乙個分隔符 空格 預設...

python中print()函式裡的

一些入門書籍沒有介紹print 函式這一格式化輸出方法,有的同學看到這裡會有疑惑。說明 字元 標記轉換說明符 str the length of s is d runoob len runoob print str the length of runoob is 6或者 x hex 十六進製制 d ...

python中print函式的引數

在python中,print預設向螢幕輸出指定的文字,例如 print hello,world hello world print的完整格式為print objects,sep,end,file,flush 其中後面4個為可選引數 sep 在輸出字串之間插入指定字串,預設是空,例如 print a ...