亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

python中print()函數(shù)的“,”與java中System.out.print()函數(shù)中的“+”功能詳解

 更新時間:2017年11月24日 09:25:33   作者:零柒玖六  
python中的print()函數(shù)和java中的System.out.print()函數(shù)都有著打印字符串的功能。接下來通過本文給大家分享python中print()函數(shù)的“,”與java中System.out.print()函數(shù)中的“+”功能,需要的朋友參考下吧

python中的print()函數(shù)和java中的System.out.print()函數(shù)都有著打印字符串的功能。

python中:

print("hello,world!")

輸出結(jié)果為:hello,world!

java中:

System.out.print("hello,world!");

輸出結(jié)果為:hello,world!

我們可以看到,這兩個函數(shù)的用法是一樣的

print()函數(shù)還有這種用法:

print("1+1=",1+1)

輸出結(jié)果為:1+1= 2

同樣的,Java中也有:

System.out.print("1+1="+(1+1));

輸出結(jié)果為:1+1=2

我們發(fā)現(xiàn),在使用print()函數(shù)的時候,我們用了一個“,”將“1+1=”和1+1的結(jié)果連接起來了,這個“,”起著連接的作用。同時,在使用System.out.print()函數(shù)的時候,我們用了一個“+”將“1+1=”和1+1的結(jié)果連接起來了,這個“+”也是起著連接作用

我們再來看他們的輸出結(jié)果,print()輸出的是1+1= 2,“=”與“2”之間有一個空格,而System.out.print()輸出的是1+1=2,“=”與“2”之間沒有空格。這里我們發(fā)現(xiàn)python中的print()函數(shù)中的“,”不僅起著連接字符串的作用,而且還表示一個空格

總結(jié):

  1.python中的print()函數(shù)的作用和java中的System.out.print()函數(shù)的作用是一樣的

  2.print()函數(shù)中“,”和System.out.print()函數(shù)中“+”都有著連接字符串的作用

  3.print()函數(shù)中“,”還表示一個空格

  4.不同的語言都有著很多的相似點,不同的語言又有著不同的新特性

PS:下面看下java中的System.out.print()與System.out.println()的區(qū)別

System.out.print();與System.out.println();

前者輸出不換行,比如:

System.out.print("a");
System.out.print("b");

結(jié)果:

ab

后者輸出后換行,比如:

System.out.println("a");
System.out.println("b");

結(jié)果:

a
b

總結(jié)

以上所述是小編給大家介紹的python中print()函數(shù)的“,”與java中System.out.print()函數(shù)中的“+”功能詳解,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評論