002_c、print(name_1, name_2) 与 print(name_1 + name_2) 区别

  

print(name_1, name_2) : 与  print(name_1 + name_2) 区别 代码如下:

name_1 = 'jack'
name_2 = 'Tony'

#
print('首富', name_1, name_2)

#  +号必须数据类型相同,逗号不需要
print('首富' + name_1 + name_2)

执行结果如下:

name_1 + name_2  属于字符串拼接;

print(name_1, name_2) : 属于输出格式,带空格 ;

D:\SkyWorkSpace\WorkSpace\Pytest\Temp\day06\venv\Scripts\python.exe D:/SkyWorkSpace/WorkSpace/Pytest/Temp/day06/gggg/demo.py
首富 jack Tony
首富jackTony

Process finished with exit code 0

 

posted @ 2021-07-24 23:53  空-山-新-雨  阅读(143)  评论(0编辑  收藏  举报