-2

我有一个 excel 表,我需要从中创建一个 Python 函数,定义“Go”的百分比位于 Motion 行中。
运动行有 16 个(开始)和 4 个(停止),总共 20 个。

我想出了这个 python 代码,但它不能按需要运行

if Motion = 20:
       Go = FormSet.GetFieldValue(CurrentForm, "16")
       Stop = FormSet.GetFieldValue(CurrentForm, "4")
       delta = float(20 - 16) / 100
       print( '( (go) are what percentage of the field [motion]: ', acount)))

我真的很挣扎。如果有人可以帮助我,那就太好了。

4

2 回答 2

0

The answer is 80%.

For Python 3:

>>> a=16
>>> b=4
>>> (a/(a+b))*100
80.0

For Python 2:

>>> a=16
>>> b=4
>>> (a/float(a+b))*100
80.0
于 2013-03-12T12:01:32.373 回答
0

this is probably a typo:

if Motion = 20

or you really mean to do this:

if Motion == 20:

Other than this I don´t see any obvious mistakes (except that I don't get what you are trying to print)

于 2013-03-12T12:01:41.803 回答