交互式命令行:
print()
函数可以用于输出指定的字符串
[root@localhost ~]# python #进入交互式界面
Python 2.6.6 (r266:84292, Jul 23 2015, 14:41:34)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hello!word") #注意格式
hello!word
>>> exit() #退出
Python脚本:
[root@localhost ~]# vim a.py
#!/bin/env python
print("hello!word")
[root@localhost ~]# chmod +x a.py
[root@localhost ~]# ./a.py
hello!word
本文转自 zengwj1949 51CTO博客,原文链接:http://blog.51cto.com/zengwj1949/1918543