按照编程传统,先来输出一个"Hello,World!",过程相当简单,直接上命令和结果:

    >>> print "Hello,World!"
    Hello,World!

    在百度百科上提到“……,在国外用Python做科学计算的研究机构日益增多,……”,接下来搞几个我儿子学习的算数题试试:

    >>> 10+3
    13
    >>> 12+18
    30

    我在计算器上验证了一下,10+3=13没错,12+16=28才对呢,这是怎么回事!!!


    在实际应用当中应该把输入存入文件,再次使用的时候直接用就行了,不会像上面都说不清是记忆错误还是输入错误的问题了。


    接下来把 print "Hello,World!"存入hello.py

[root@Python-Test pythontest]# cat >> hello.py <<EOF
> print "Hello,world!"
> EOF
[root@Python-Test pythontest]# ll
total 4
-rw-r--r--. 1 root root 21 Feb  6 13:09 hello.py
[root@Python-Test pythontest]# chmod +x hello.py 
[root@Python-Test pythontest]# ll
total 4
-rwxr-xr-x. 1 root root 21 Feb  6 13:09 hello.py
[root@Python-Test pythontest]# ./hello.py 
./hello.py: line 1: print: command not found
[root@Python-Test pythontest]# python hello.py
Hello,world!

为啥直接不能执行呢?在程序中第一行位置加入#!/usr/bin/env python

[root@Python-Test pythontest]# cat hello.py 
#!/usr/bin/env python
print "Hello,world!"
[root@Python-Test pythontest]# ./hello.py 
Hello,world!


先到这里了,明天继续