首页 > 解决方案 > 如何将变量从python传递到php?

问题描述

我正在做一个项目,我在 python 中从 google sheet 读取数据。这里我将变量从 php 脚本传递给 python,然后在 python 中我正在做一些计算。现在我想将这些变量从 python 发送回 php 脚本。我怎么做 ?

username=sys.argv[1]
print(username)

for row in range(1,100):
    if wks.cell(row,2).value== username:
        n=row
        break

print(n)        



apti=0

if wks.cell(n,4).value == "1060":
    apti+=1

if wks.cell(n,5).value == "20 yrs":
    apti+=1 

if wks.cell(n,6).value == "25":
    apti+=1

if wks.cell(n,7).value == "250":
    apti+=1

if wks.cell(n,8).value == "6":
    apti+=1

if wks.cell(n,9).value == "12":
    apti+=1

if wks.cell(n,10).value == "48":
    apti+=1

if wks.cell(n,11).value == "1 and 2 only":
    apti+=1

if wks.cell(n,12).value == "41":
    apti+=1



if apti==9:
    print('success')
else:
    print ('Fail')  

count=10

现在我想将 count 变量的值发送回 php 脚本

标签: phppython

解决方案


欢迎来到 SO。我认为您正在使用 Google API 来读取单元格值并进行一些计算。我建议您将最终的我们的值写入工作表,然后尝试使用 php 接口从工作表中读取。因此,谷歌表充当您的数据库。

# At the end of python case, update sheet with final value
sheet.update_cell(...)

要使用 php 从更新的 google sheet 中读取,请参阅此处的文档:https ://developers.google.com/sheets/api/quickstart/php

希望这可以帮助 !


推荐阅读