gpt4 book ai didi

python-3.x - 在 Python 中将请求发布到 Slack

转载 作者:行者123 更新时间:2023-12-02 08:19:46 24 4
gpt4 key购买 nike

我正在编写一个脚本来读取两个 CSV 文件之间的差异。读出后,我应该使用 WebHook 将比较结果联系到松弛页面。我在发送 Post 方法时遇到困难。

slack 提供的链接生成 400 的响应在末尾使用/post 或 :8080 你会得到一个 200,但 slack 页面中没有弹出任何内容。

有什么想法或建议吗?

    def main():
csvDiff()
#print(l)
post()

def csvDiff():
f = open("new.csv")
csv_f = csv.reader(f)
old=set(pd.read_csv("old.csv", index_col=False, header=None)[0]) #reads the csv, takes only the first column and creates a set out of it.
new=set(pd.read_csv("new.csv", index_col=False, header=None)[0]) #same here
diff = new - old
#Convert the diff set into a list
diff=list(diff)
#print(diff)
#print(newConnections)
for row in csv_f:
if row[0] in diff:
l.append(row)

def makeCsv():
l = pd.to_csv

def post():
url = 'whatever'
payload={"text": "A very important thing has occurred! <https://alert-system.com/alerts/1234|Click here> for details!"}
r = requests.post(url, data=json.dumps(l).encode('utf8'))
print(r)

if __name__ == "__main__":
main()

最佳答案

试试这一行:

r = requests.post(url, json=payload)

关于python-3.x - 在 Python 中将请求发布到 Slack,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38375937/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com