pthon3.3...print,出错的问题。。。。

一位初学者在尝试用Python3.3编写'Hello World'程序时遇到了语法错误,代码`print 'hello'`导致了`SyntaxError: invalid syntax`的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

刚开始学python,跟这书上打个hello world  结果出错了。。。。快哭了

python 

print'hello'

File "<stdin>",line 1 print 'hello' SyntaxError:invalid syntax


>>> print 'hello'
  File "<stdin>", line 1
    print 'hello'
                ^

SyntaxError: invalid syntax

print ( *objectssep=' 'end='\n'file=sys.stdoutflush=False )

Print objects to the stream file, separated by sep and followed by endsepend 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 andend 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 Nonesys.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语句在3.0后已经被换成和print()函数,具体用法见上方的官方说明

 查看3.0文档:http://docs.python.org/release/3.0.1/whatsnew/3.0.html
print()。文档是这样写的:The print statement has been replaced with a print() function, with keyword arguments to replace most of the special syntax of the old print statement (PEP 3105).
print语句被print()方法代替,旧print语句中的特定的语法被参数代替。
所以呢,hello world!应该写成这样:print ("hello world!")



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值