我正在使用一个包含类似于Excel的电子表格的软件,但是它不允许我使用数组。 这是我在Excel中使用的简化公式:
<form action="{% url 'sum:index' %}" method="post">
{% csrf_token %}
<div class="container">
<div class="row">
<div class="col-4"></div>
<div class="col-md-4 offset-md-4">
<table class="table borderless">
<thead>
</thead>
<tbody>
<tr>
<td><input type="text" name="int1" class="form-control" disabled="disabled" value=" {{ num1 }} "></td>
<td>+</td>
<td><input type="text" name="int2" class="form-control" disabled="disabled" value=" {{ num2 }} "></td>
<td>=</td>
<td> {{ form.as_p }} </td>
</tr>
</tbody>
</table>
<table class="table borderless">
<thead>
</thead>
<tbody>
<tr>
<td style="text-align: right;"><input type="submit" name="randomize" class="btn btn-default" value="New"></td>
<td><input type="submit" name="check" class="btn btn-primary" value="Check"></td>
</tr>
</tbody>
</table>
<hr>
<div class="exclamation">
<span> {{ exclam }} </span>
</div>
</div>
</div>
</div>
</form>
我的想法是使用公式重新创建数组:
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/sum/
Django Version: 2.1.3
Python Version: 3.7.1
Installed Applications:
['sum.apps.SumConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
126. response = self.process_exception_by_middleware(e, request)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
124. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Applications/MAMP/htdocs/sum_py/sum/views.py" in index
19. num1 = int(request.POST.get('int1'))
Exception Type: TypeError at /sum/
Exception Value: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
在范围=LOOKUP(2,1/((A1:A9>A10)-(A1:A9<A10)))
上;和公式:
IF(A1>A10,1,0)
IF(A2>A10,1,0)
...
在范围C10:K10
然后进行数学运算并完成LOOKUP函数以查看“重新创建的数组”。
问题可能是很长的范围,即IF(A1<A10,1,0)
IF(A2<A10,1,0)
...
所需的列数,并且需要向下拖动公式以增加很多单元格公式编号。
是否有更好的方法可以在不使用数组的情况下获得第一个公式的相同结果?