python中print()函数的“,”与java中System.out.print()函数中的“+”功能详解
作者:零柒玖六 时间:2021-12-18 10:27:02
python中的print()函数和java中的System.out.print()函数都有着打印字符串的功能。
python中:
print("hello,world!")
输出结果为:hello,world!
java中:
System.out.print("hello,world!");
输出结果为:hello,world!
我们可以看到,这两个函数的用法是一样的
print()函数还有这种用法:
print("1+1=",1+1)
输出结果为:1+1= 2
同样的,Java中也有:
System.out.print("1+1="+(1+1));
输出结果为:1+1=2
我们发现,在使用print()函数的时候,我们用了一个“,”将“1+1=”和1+1的结果连接起来了,这个“,”起着连接的作用。同时,在使用System.out.print()函数的时候,我们用了一个“+”将“1+1=”和1+1的结果连接起来了,这个“+”也是起着连接作用
我们再来看他们的输出结果,print()输出的是1+1= 2,“=”与“2”之间有一个空格,而System.out.print()输出的是1+1=2,“=”与“2”之间没有空格。这里我们发现python中的print()函数中的“,”不仅起着连接字符串的作用,而且还表示一个空格
总结:
1.python中的print()函数的作用和java中的System.out.print()函数的作用是一样的
2.print()函数中“,”和System.out.print()函数中“+”都有着连接字符串的作用
3.print()函数中“,”还表示一个空格
4.不同的语言都有着很多的相似点,不同的语言又有着不同的新特性
PS:下面看下java中的System.out.print()与System.out.println()的区别
System.out.print();与System.out.println();
前者输出不换行,比如:
System.out.print("a");
System.out.print("b");
结果:
ab
后者输出后换行,比如:
System.out.println("a");
System.out.println("b");
结果:
a
b
总结
以上所述是小编给大家介绍的python中print()函数的“,”与java中System.out.print()函数中的“+”功能详解网站的支持!
来源:http://www.cnblogs.com/0796blogs/p/7885642.html?utm_source=tuicool&utm_medium=referral
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
MySQL Order By索引优化
使用Python编写类UNIX系统的命令行工具的教程
asp事务处理的另外一个方法
隐藏修改文件时间和文件属性的ASP脚本
简单理解PHP的面向对象编程方式
从零开始写jQuery框架
三分钟掌握PHP操作数据库
![](https://img.aspxhome.com/file/2023/9/55279_0s.png)
php输出xml必须header的解决方法
PHP实现的XXTEA加密解密算法示例
谈谈设计师的发展
Python使用ClickHouse的实践与踩坑记录
![](https://img.aspxhome.com/file/2023/3/59643_0s.jpg)
正则 global 属性介绍
MySQL优化之数据表的处理
Oracle 9i 数据库异常关闭后的启动
asp如何实现强制登录注册?
PHP CURL CURLOPT参数说明(curl_setopt)
oracle 发送邮件 实现方法
DW实现滚动新闻
CSS在Internet Explorer 6, 7 和8中的差别
![](https://img.aspxhome.com/file/UploadPic/up/2009102618430043.gif)