关于python中不同版本的print区别

最近有时候会看看python的一些东西。也看了一些入门教程,但是发现一个问题是,在用print的时候老是报错:

报错如下:

提示print a这句有语法问题。但是看的教程里面都有这样写的,没有问题啊。

忽然想到以前同学说过python2系列和3系列里面有区别的。就上网查了一下。解释如下:

print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False) 
Print objects to the stream file, separated by sep and followed by end. sep, end and file, if present, must be given as keyword arguments.

All non-keyword arguments are converted to strings like str() does and written to the stream, separated by sep and followed by end. Both sep and end must be strings; they can also be None, which means to use the default values. If no objects are given, print() will just write end.

The file argument must be an object with a write(string) method; if it is not present or None, sys.stdout will be used. Whether output is buffered is usually determined by file, but if the flush keyword argument is true, the stream is forcibly flushed.

Changed in version 3.3: Added the flush keyword argument.
对print解释如下:将对象输出到文件终端,通过sep进行分割,默认是空格,同时以end结尾,默认\n,就是换行。输出的目的地是文件,默认是stdout。如果flushed=true,数据会被立即写到文件中去。

根据print的接口描述,将代码修改如下即可:


这个是由于Python的解释器的版本不同引起的。所以在学习的时候有可能用的是3系列的版本,但是看到参考资料是基于2系列的,所以学习的时候要注意下。

-----------ceshi

final FieldsetPanel fs = gridBuilder.newFieldset(getString("description"), true);
final IModel<String> model = new PropertyModel<String>(data, "description");
			
TextArea taskDescArea = new TextArea(taskDescAreaId, model);
fs.add(taskDescArea).setAutogrow();
taskDescArea.add(new AttributeModifier("id", true, new Model(taskDescAreaId)));

转载于:https://my.oschina.net/myspaceNUAA/blog/127101

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值