Processamento de Dados no Shell
Susan Sun
Data Person
Python
Documentação:
man python
...
-V , --version
Prints the Python version number of the executable and exits.
python --version
Python 3.5.2
Exemplo: usando o Python nativo
which python
/usr/bin/python
Para abrir uma sessão interativa do Python no terminal:
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.
>>>
Dentro da sessão interativa, use apenas sintaxe Python:
>>> print('hello world')
hello world
Para sair do Python e voltar ao terminal:
>>> exit()
$
Sessão interativa do Python:
Alternativa:
.pypython + nome do arquivoMétodo 1
.py usando um editor de texto no terminal (ex.: nano, Vim, Emacs)
Método 2
.py enviando com echo a sintaxe Python para hello_world.py, criando o arquivo no mesmo passo.echo "print('hello world')" > hello_world.py
Conferir o conteúdo do arquivo:
cat hello_world.py
print('hello world')
Garanta que você está no mesmo diretório do arquivo .py:
ls
hello_world.py
Execute o arquivo .py precedendo o nome com python:
python hello_world.py
hello world
Processamento de Dados no Shell