hello
>>> mystring = 'aa'
>>> print(mystring)
aa
下划线(_)在解释器中有特别的含义,表示最后一个表达式的值
>>> a="22"
>>> _
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name '_' is not defined
>>> a
'22'
>>> _
'22'
程序输入和raw_input()内建函数
Python 的print 语句,与字符串格式运算符( % )结合使用,可实现字符串替换功能
>>> print("%s is %d" % ("ss",0))
ss is 0
ss is 0
>>> logfile = open('1.txt', 'a')
>>> print >> logfile, 'Fatal error: invalid input!'
>>> logfile.close()
>>> print >> logfile, 'Fatal error: invalid input!'
>>> logfile.close()
>>> user = raw_input('Enter login name: ')
Enter login name: daf
>>> print 'Your login is:', user
Your login is: daf
Enter login name: daf
>>> print 'Your login is:', user
Your login is: daf
注释
#
文档字符串 :你可以在模块、类或者函数的起始添加一个字符串,起到在线文档的功能
def foo():
"This is a doc string."
return True
"This is a doc string."
return True