调用Python的print函数出问题

来源:互联网 发布:mac 命令行卸载软件 编辑:程序博客网 时间:2024/05/21 10:29
想尝试一下Python中的最简单的输入:print函数的用法lzzh@lzzh-VirtualBox:~/Desktop$ vim test.py


然后在test.py中输入以下命令:

password = raw_input("Please input the PASSWORD:")print 'The password you have inputed is ',password

保存后运行出现这个问题:


如图:显示语法错误,在调用print函数时没有括号,于是改为用如下命令运行:

lzzh@lzzh-VirtualBox:~/Desktop$ python test.py

可行!

结果如下:

Please input the PASSWORD:fafafafaThe password you have inputed is  fafafafa


总结:


1. 使用Python2版本时print函数可以不使用括号括起来,

2. Python3 版本对print函数进行了更改,其要求用括号()将要输出的内容进行括入。


原创粉丝点击