Automation Anywhere 中的 Python 脚本未返回任何内容(Python 设置正确)

问题描述 投票:0回答:2

我在我的 Automation Anywhere 360 机器人中包含了一个 Python 脚本,但运行机器人时没有任何反应。这意味着我没有收到错误消息。我在安装了 Python 的本地设备上运行该机器人。环境变量设置正确(用cmd检查)。

代码非常简单。

import pandas as pd
import numpy as np
import os
import openpyxl

def excel_split():
    excel = pd.read_excel("some excel.xls")
    column_name = 'Name'
    unique_values = excel[column_name].unique()

    for unique_value in unique_values:
        df_output = excel[excel[column_name].str.contains(unique_value)]
        output_path = os.path.join('file path in another folder', unique_value + '.xlsx')
        df_output.to_excel(output_path, index=False)

print(excel_split())

基本上,Python 脚本采用我之前在机器人中创建的 Excel,然后根据列拆分 Excel。之后,分割的 Excel 文件将保存到另一个文件夹中。 在 Visual Studio Code 中执行时,脚本运行良好。但正如前面所描述的,什么也没有发生。该错误一定是在 Python 中,因为当我使用一个返回一些文本的简单函数进行一些测试时,它可以工作。示例:

def greet():
  return 'Hello A360! from Python'

print(greet())

然后我通过消息框打印出来。

我很高兴收到任何提示!

python excel automation operating-system automationanywhere
2个回答
1
投票

如果我没记错的话,似乎您只是忘记在函数中使用

return <output>
。 在Python中,如果你不明确使用
return
,它只是默认为
return None
,这就是为什么你看不到任何东西


0
投票

打印在任何地方的自动化中都不起作用,而是您可以将消息返回到任何地方的自动化,并且相同的信息将在自动化任何地方的变量中获取。

© www.soinside.com 2019 - 2024. All rights reserved.