[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 !