yumoz

Python基础之print函数

 1 import time
 2 #一般输出
 3 print('hello,world')
 4 a = [1,2,3]
 5 print([1,2,3])
 6 print(a)
 7 
 8 # 格式化控制
 9 s = 'Hello'
10 z = 'world'
11 
12 x = len(s)
13 print("The length of %s is %d" %(s,x))
14 print(x,end=' ') #指定不换行,因为Python默认换行
15 print('hello')
16 
17 #字符串的拼接
18 print(s+z)
19 
20 # 2的3次幂对5取模
21 print(pow(2,3,5))
22 
23 print("Loading",end=" ")
24 for i in range(20):
25     print(".",end='',flush = True)
26     time.sleep(0.5)
27 运行结果:
28 hello,world
29 [1, 2, 3]
30 [1, 2, 3]
31 The length of Hello is 5
32 5 hello
33 Helloworld
34 3
35 Loading ....................

一段程序简单介绍如何使用Python中的print函数,其他详细内容随后再补。


 

posted @ 2020-09-08 20:29  yumoz  阅读(266)  评论(0编辑  收藏  举报