(1) 建一个hello.py
[hadoop@slave1 桌面]$ vi hello.py
Hello World!
或者:
(4)执行
[hadoop@slave1 桌面]$ python hello.py
Hello World!
x:125
y:2
250
I will begin to learn python,come on !
[hadoop@slave1 桌面]$ vi hello.py
点击(此处)折叠或打开
- print("Hello World!")
(2)通过"python *.py"运行python脚本
[hadoop@slave1 桌面]$ python hello.py
Hello World!
或者:
点击(此处)折叠或打开
- $ python
- Python 2.6.6 (r266:84292, Feb 21 2013, 23:54:59)
- [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
- Type "help", "copyright", "credits" or "license" for more information.
- >>> print "hello world"
- hello world
(3)接受用户输入
[hadoop@slave1 桌面]$ vi hello.py
点击(此处)折叠或打开
- print("Hello World!")
- x=input("x:")
- y=input("y:")
- print(x*y)
- print("I will begin to learn python,come on !")
[hadoop@slave1 桌面]$ python hello.py
Hello World!
x:125
y:2
250
I will begin to learn python,come on !
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26129555/viewspace-2142293/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26129555/viewspace-2142293/