python3.x 与python2.x print的区别 input区别

#python3.x 与python2.x print的区别  input区别
#python3.x
# print(x,y)   #打印对象
# #python2.x
# print x,y

# #python3.x
# print(x,y,end="")
# #python2.x
# print x,y,

#echo "aa" >> 1.txt
#python3.x   把内容追加到文件
with open("1.py","a",encoding="utf-8") as f:
    print("11",file=f)

#python2.x
# with open("1.py","a",encoding="utf-8") as f:
#     print >> f,"hhh"
#
    
#print  其实是调用了sys.stdout.write

# In [9]: print("1")
# 1
#
# In [10]: sys.stdout.write("1"+"\n")
# 1
#
#这两行代码等价


#python3.x  sep  #多个字符串用什么链接
print("12","3")
print("12","3",sep="+")


#input()区别
#python2.x
    #input()    自动识别输入的参数,并转换
    #raw_input()  #默认都是字符串类型
    
#python3.x
#raw_input()与input() 整合
input()  #全部按字符串处理

 

你可能感兴趣的:(python基础笔记,大秋神,python2,python3)