相当于Python或MYSQL中的Excel目标searchfunction

我将如何使用Python或MySQL实现Excel目标查找function?

这是场景:

在我工作的机构,他们购买物品,然后出售给在线商店,这个网上商店申请3个不同的费用,计算最终的价格。 该机构想要在最终价格上赚取固定的金额,所以我需要计算出他们想要赚取的费用和金额的最终价格。

我知道他们想赚取的金额和初始价格,以及费用,我不知道我需要卖什么样的价格来赚取这些特定的金额。

随着Excel中他们使用目标searchfunction,计算最终价格与所有的费用和代理商想要获得的固定金额,我想用python或mysql做到这一点。

EX:

a1 = 270.0$ # This is the price they buy the item c2 = 3.50$ # This is the shipping Price c3 = 0.10 # This is the FEE of the store in percentage (10%) c4 = 0.03 # This is the FEE for the credit card (0.3%) c5 = 0.35$ # This is the Fixed FEE for the store 0.35$ d1 = 5$ # This is the amount they want to earn when they sell the item x = ? # This is the final price they need to sell the item for earn d1 

谢谢你的帮助

在Python中,您可以执行以下操作。 注意formumla可能需要调整

 a1 = 270.00 # This is the price they buy the item in $ c2 = 3.50 # This is the shipping Price in $ c3 = 0.10 # This is the FEE of the store in percentage (10%) c4 = 0.03 # This is the FEE for the credit card (0.3%) c5 = 0.35 # This is the Fixed FEE for the store $0.35 d1 = 5.00 # This is the amount they want to earn when they sell the item in $ x = 0.00 # This is the final price they need to sell the item for earn d1 while True: # Assumed Formula - this may need to be adjusted to match your criteria earnt_amount = ((x - a1 - c2) * (1 - c3 - c4)) - c5 x += 0.01 if earnt_amount >= d1: break print ('Price "x" should be: {0}'.format(x))