UiPath Documentation
activities
latest
false
Importante :
A tradução automática foi aplicada parcialmente neste conteúdo. A localização de um conteúdo recém-publicado pode levar de 1 a 2 semanas para ficar disponível.

Atividades do desenvolvedor

Última atualização 21 de mai de 2026

Gerenciar de scripts do Python

O exemplo a seguir explica como executar automaticamente um código do Python criado no runtime e escrever um log de arquivo. Apresenta atividades como Python Scope e Run Python Script. Você pode encontrar essas atividades no pacote UiPath.Python.Activities.

Observação:

Before running any Python workflow, make sure that you have Python3 installed.

É assim que um processo de automação pode ser construído:

  1. Abra o Studio e crie um Processo.

  2. Arraste um contêiner Sequência para o Designer de Fluxo de Trabalho.

  3. Crie um novo argumento:

    Argument nameDirectionTipo de ArgumentoValor Padrão
    in_PythonPathEmStringAdicione o caminho da pasta onde o Python foi instalado
  4. Drag an If activity inside the Sequence container.

    • Adicione a expressão String.IsNullOrEmpty(in_PythonPath) orelse not Directory.Exists(in_PythonPath) no campo Condição.
  5. Drag a Sequence container in the Then field of the If activity.

  6. Drag a Message Box activity inside the Sequence container.

    • In the Properties panel, add the expression "Error" in the Caption field.
    • Adicione a expressão "Pyhon Path not configured. Please configure path by setting the argument 'in_PythonPath'." no campo Texto.
  7. Arraste uma atividade Terminate Workflow após a atividade Message Box.

    • In the Properties panel, add the expression "Input Arguments not correct" in the Reason field.
  8. Arraste uma atividade Python Scope após a atividade If.

    • In the Properties panel, add the argument in_PythonPath in the Path field.
    • Select your Python version from the Version drop-down list (Python_36 in this example).
  9. Drag a Run Python Script activity inside the Python Scope container.

    • In the Properties panel, add the following code snippet in the Code field:
      String.Format(
      "import sys" + Environment.NewLine _
      + "import os " + Environment.NewLine _
      + "with open('{0}\logs.txt', 'w') as f: " + Environment.NewLine _
      +     "    f.write('Starting script! \n')" + Environment.NewLine  _
      +     "    f.write('Computing!\n')" + Environment.NewLine _
      +     "    f.write('Finishing script! \n')" + Environment.NewLine, _
      Directory.GetCurrentDirectory.Replace("\", "\\"))
      String.Format(
      "import sys" + Environment.NewLine _
      + "import os " + Environment.NewLine _
      + "with open('{0}\logs.txt', 'w') as f: " + Environment.NewLine _
      +     "    f.write('Starting script! \n')" + Environment.NewLine  _
      +     "    f.write('Computing!\n')" + Environment.NewLine _
      +     "    f.write('Finishing script! \n')" + Environment.NewLine, _
      Directory.GetCurrentDirectory.Replace("\", "\\"))
      
  10. Execute o processo. A automação executa o código Python e grava um log em um arquivo denominado logs.txt.

Esta página foi útil?

Conectar

Precisa de ajuda? Suporte

Quer aprender? Academia UiPath

Tem perguntas? Fórum do UiPath

Fique por dentro das novidades