查看python版本
C:\>python -V
Python 2.7.5
退出python
exit()
ctrl+Z
第一个程序
>>> print 'hello world'
hello world
>>> print "hello world"
hello world
>>> print ('hello,world')
hello,world
变量
>>> a=1
>>> a
1
>>> a=23456786
>>> a
23456786
>>> a=1.87543368
>>> a
1.87543368
>>> a=1i+2j
File "<stdin>", line 1
a=1i+2j
^
SyntaxError: invalid syntax
>>> a=1+2j
>>> a
(1+2j)
>>> _a=2
>>> _a
2
>>> _A
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name '_A' is not defined
#python中要区分大小写
>>> username='cindy'
>>> username
'cindy'
>>> pi=3.14
>>> pi
3.14
>>> print
>>> print pi
3.14
查看数据类型
>>> a=3.14
>>> type(a)
<type 'float'>
>>> a='abc'
>>> type(a)
<type 'str'>
>>> a=abc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'abc' is not defined
>>> a=0
>>> type(a)
<type 'int'>
>>> a=True
>>> type(a)
<type 'bool'>
换行输出数据,用三个引号
>>> a="""1
... 2
... 3
... 0
... """
>>> print a
1
2
3
0
>>> a
'1\n2\n3\n0\n'
>>>
>>>
换行输出数据,用\n
>>> a='1\n2'
>>> a
'1\n2'
>>> print a
1
2
求加、减、乘、除、幂
>>> num1=3.14
>>> num2=5
>>> print num1+num2
8.14
>>> print num1-num2
-1.86
>>> print num1*num2
15.7
>>> print num1/num2
0.628
>>> print num1**num2
305.244776182
>>>
求除、余
>>> num1=89
>>> num2=10
>>> print num1/num2
8
>>> print num1%num2
9