欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時(shí)間:2017年11月24日 09:25:33   作者:零柒玖六  
python中的print()函數(shù)和java中的System.out.print()函數(shù)都有著打印字符串的功能。接下來(lái)通過(guò)本文給大家分享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!

我們可以看到,這兩個(gè)函數(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ù)的時(shí)候,我們用了一個(gè)“,”將“1+1=”和1+1的結(jié)果連接起來(lái)了,這個(gè)“,”起著連接的作用。同時(shí),在使用System.out.print()函數(shù)的時(shí)候,我們用了一個(gè)“+”將“1+1=”和1+1的結(jié)果連接起來(lái)了,這個(gè)“+”也是起著連接作用

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

總結(jié):

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

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

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

  4.不同的語(yǔ)言都有著很多的相似點(diǎn),不同的語(yǔ)言又有著不同的新特性

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ù)中的“+”功能詳解,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論