Leggi e rivedi la documentazione di Automation Anywhere

Automation 360

Chiudi contenuti

Contenuti

Apri contenuti

Example of using Python script to join a list

  • Aggiornato: 2021/06/03
    • Automation 360 v.x
    • Crea
    • Spazio di lavoro RPA
    • Esempi

Example of using Python script to join a list

Build a bot that uses a Python function to print the message Go Be Great!, the Automation Anywhere version of Hello World. In this example, the bot combines a list of string values and prints them to a message box.

Prerequisiti

To run Python script from Automation 360, you must already have the latest version of Python 3.x installed on your device.

Procedura

  1. Apri un nuovo bot:
    1. Nel pannello di sinistra, fai clic su Automazione.
    2. Fai clic su Crea nuovo > Bot.

    3. Nella finestra Crea Task Bot, immetti un nome per il bot. Per ulteriori informazioni sulla scelta dei nomi bot vedere bot convenzioni di denominazione.
    4. Accetta la posizione predefinita della cartella \Bot\.
      Per cambiare la posizione in cui viene memorizzato il bot, fai clic su Scegli e segui i prompt.
    5. Fai clic su Crea e modifica.
  2. Create a variable to hold the list values:
    1. Click the Create variable icon.
    2. Enter lArgument in the Name field.
      Recommendation: Prefix the variable name with a lowercase character to indicate the variable data type.

      Denominazione delle variabili

    3. Select the List type and String subtype.
    4. In the Default value field, enter the following values:
      1. Value at 0: Go
      2. Value at 1: Be
      3. Value at 2: Great
      4. Value at 3: !
    5. Fai clic su Crea.
  3. Provide the script with a Python Script > Open action:
    1. Double-click or drag the Python Script > Open.
    2. Select the Manual input option.
    3. Copy and paste the following text into the Enter script here field.
      def data ( str ):
          x = " ".join( str )
          return x
  4. Use a Python Script > Execute function action to tell the bot to run the script:
    1. Double-click or drag Python Script > Execute function.
    2. Enter data in the Enter name of function to be executed field.
    3. Select the lArgument variable from the Arguments to the function drop-down list.
    4. Create the variable sOutput for the Assign the output to variable field.
  5. Insert a Message box action to hold the Python function output:
    1. Double-click or drag the Message box > Message box action.
    2. In the Enter the message to display field, select and insert the variable sOutput.
    3. Select the Close message box after option. Retain the default value of 5 seconds in the field.
  6. Close the script execution session with a Python Script > Close action:
    1. Double-click or drag Python Script > Close.
    2. Fai clic su Salva.
  7. Click the Run icon.
    The bot generates a message box with the text Go Be Great!. After 5 seconds, the message box disappears.

    To review the bot launcher logs, navigate to C:\ProgramData\AutomationAnywhere\BotRunner\Logs\<current month>\Bot_Launcher-<today's date>.log.zip. Each zipped folder contains a file with data on the code execution, which is useful for debugging.

Invia feedback