Shell 中的数据处理
Susan Sun
Data Person
Python
文档:
man python
...
-V , --version
Prints the Python version number of the executable and exits.
python --version
Python 3.5.2
示例:使用系统自带 Python
which python
/usr/bin/python
在终端启动 Python 交互式会话:
python
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linuxType "help", "copyright", "credits" or
"license" for more information.
>>>
在会话中仅使用 Python 语法:
>>> print('hello world')
hello world
退出会话返回终端:
>>> exit()
$
Python 交互式会话:
替代方案:
.py 脚本python + 脚本来执行方法 1
.py 文件(如 nano、Vim、Emacs)
方法 2
echo 将 Python 语句写入 hello_world.py,同时创建文件。echo "print('hello world')" > hello_world.py
校验文件内容:
cat hello_world.py
print('hello world')
确保与 .py 文件在同一目录:
ls
hello_world.py
在文件名前加 python 来执行:
python hello_world.py
hello world
Shell 中的数据处理