python核心编程python核心编程
Python学习笔记(一)

python核心编程(第二版)的代码示例已经不支持python 3.0以上版本,学习都是边学边记录,所以决定重新学习python的同时,也决定将学习笔记记录下来,一方面是方便他人参考,最重要的就是给自己加深印象。一、程序输出1、print输出python 2.7:>>> print 'hello'python 3.3:>>> print('hello')hello2、print重定向python 2.7:>>> import sys>>> logfile = open('G:\\1.txt','a')>>> print >> logfile,'hello'python 3.3:>>> import sys>>> logfile = open('G:\\1.txt','a')>>> print('hello',file = logfile)>>> logfile.close()二、程序输入(内建函数)python 2.7:>>> user = raw_input('Enter your num: ')python 3.3:>>> user = input('Enter your num: ')Enter your num: 23>>> print('the num is %d' % (int(user) * 2))the num is 46
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-25923-1.html
在北上广都没问题
说别人幼稚的你真幼稚
怎么这么多愤青