【iTestCat】Python2\Python3输入输出及区别(Python3自动化教程)

1.1输出

python2中输出可以使用空格或者小括号。

示例:
print "hello itestcat"
或者
print("hello itestcat")
 

python3中输出只能小括号。

示例:
print("hello itestcat")

1.2 输入

Python2中,raw_input()获取用户的原始输入,input()会把用户输入的内容当做代码来执行。

raw_input()示例:
itestcat = raw_input("please input:")
print itestcat
input()示例:
itestcat2 = input("please input2:")
print itestcat2
【iTestCat】Python2\Python3输入输出及区别(Python3自动化教程)

python3中没有raw_input()函数,只有input(),并且 python3中的input与python2中的raw_input()功能一样。

示例:
itestcat3 = input("please input:")
print(itestcat3)
【iTestCat】Python2\Python3输入输出及区别(Python3自动化教程)

原创文章,作者:iTestCat,保留所有权利,禁止转载,如若转载,请联系作者!

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
iTestCat的头像iTestCat
上一篇 2018年12月15日 下午3:09
下一篇 2019年2月16日 下午4:31

相关推荐

发表回复

登录后才能评论