python - 在表中搜索第 1 列中的值并打印同一行第 2 列中的数据

标签 python mysql bash awk sed

我已经尽力找到这个 - grep、awk、sed - 我想在 linux shell、javaScript 或 python(或其他任何东西,但我最了解这 3 个)中执行此操作。我发布的代码是 JavaScript(我最喜欢的),但我愿意接受任何问题的答案 - 天啊,如果它能让我免于编写大量的行,我会学习一门新语言或在 Scratch 中完成它。 ..

我有一组齿轮装置的扭矩值及其相应的 ID 号列表(为了简化,我使用整数 - 左侧是扭矩值,右侧是零件号):

maxTorq:Unit ID#
100:6100
200:6105
300:6110
.......and this goes for HUNDREDS of lines.....
99990:6985
100000:6990

我当前的代码是“if...else if”语句的简单重复。 这里是! (运行它,它并不太糟糕......需要更多 CSS,在我的网站上它有一些很酷的图形和样式。)

    <!DOCTYPE html>
<html lang="en">
<style>
body {
    background-image: url("../media/sumi.jpeg");
    background-repeat: no-repeat;
    background-position: right top;
}
#main {
  max-width: 800px;
  margin: 20px auto; 
  border: solid;
  background: #87CEEB;
  padding: 50px;
  position: relative; 
}
#answer {
  max-width: 200px;
  margin: 20px auto; 
  border: solid;
  background: #FFEFD5;
  padding: 50px;
  position: relative;
  padding: 10px;
  right: 300px; 
}
</style>

<body>
<head>
    <meta charset="utf-8">
    <title>Sumitomo Sizer</title><br>

</head>
<body>
<h6> here it is:
<h1><b>Sumitomo Cyclo sizer!!</b></h1>
<div id="main">
<P> I am only showing 8 of the 18 available ratios.  Sure, you might need       the others for some reason, but you can do most things with these 8.</p>

<p>  What output speed is closest AND OVER what you need:
  <select id="vara">
<option value="11">159 RPM (11:1)</option>
<option value="17">103 RPM (17:1)</option>
<option value="29">60 RPM (29:1)</option>
<option value="35">50 RPM (35:1)</option>
<option value="43">40 RPM (43:1)</option>
<option value="59">30 RPM (59:1</option>
<option value="71">25 RPM (71:1)</option>
<option value="87">20 RPM (87:1)</option>
</select>
</p>

<P>What is your motor Horsepower @1750:
   <select id="varb">
<option value="0.5">1/2</option>
<option value="1">1</option>
<option value="1.5">1-1/2</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="5">5</option>
<option value="7.5">7.5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
</select>
</p>
<p>belt drive ratio: 
<input id="varc" type="text" value="1"/>:1
</p>
<P>Input style:
   <select id="vard">
<option value="0">Standard</option>
<option value="1">Top motor mount</option>
<option value="2">C-face (w/coupling)</option>
</select>
</p>
<p>Click the button to get your Sumitomo size</p>

<button onclick="sumisize()">Find it</button>
</p>
<div id="answer">
Sumitomo part number: <h2><p id="resultd"></h2></p><p id="resulta"></p>
Actual output speed: <p id="resultb"> </p>
Torque in inch-lbs.:<p id="resultc"></p>
</div>
<script type="text/javascript" language="javascript" charset="utf-8">

function sumisize()
{
var y = (document.getElementById('vara').value);
var v = (document.getElementById('varb').value);
var u = (document.getElementById('varc').value);
var q = (document.getElementById('vard').value);
var w=(v*36);
var t=(w*u);
var s=(t*y);
var r=((1750/u)/y);
var x="";
var z=(y);
var p=(q);
var o="";
var n="";
var m="";

if (p>0 && v==0.5)
  {
  m="-56"
  }
else if (p>0 && v==1)
  {
  m="-143"
  }
else if (p>0 && v==1.5)
  {
  m="-145"
  }
else if (p>0 && v==2)
  {
  m="-145"
  }
else if (p>0 && v==3)
  {
  m="-182"
  }
else if (p>0 && v==5)
  {
  m="-184"
  }
else if (p>0 && v==7.5)
  {
  m="-213"
  }
else if (p>0 && v==10)
  {
  m="-215"
  }
else if (p>0 && v==15)
  {
  m="-254"
  }
else if (p>0 && v==20)
  {
  m="-256"
  }
if (p==0)
  {
  o="CHH";
  }
else if (p==1)
  {
  o="CHHP";
  }
else if (p==2 && u==1)
  {
  o="CHHJ";
  }
else 
  {
  n=" Please Set 'Belt Drive Ratio' to 1 ";
  }
if (z==11 && s<=298)
  {
  x="-6080-Y11";
  }
else if (z==11 && s<=393)
  {
  x="-6085-Y11";
  }
else if (z==11 && s<=579)
  {
  x="-6090-Y11";
  }
else if (z==11 && s<=765)
  {
  x="-6095-Y11";
  }
else if (z==11 && s<=1190)
  {
  x="-6100-Y11";
  }
else if (z==11 && s<=1610)
  {
  x="-6105-Y11";
  }
else if (z==11 && s<=1790)
  {
  x="-6110-Y11";
  }
else if (z==11 && s<=1970)
  {
  x="-6115-Y11";
  }
else if (z==11 && s<=2560)
  {
  x="-6120-Y11";
  }
else if (z==11 && s<=2990)
  {
  x="-6125-Y11";
  }
else if (z==11 && s<=4730)
  {
  x="-6130-Y11";
  }
else if (z==11 && s<=5700)
  {
  x="-6135-Y11";
  }
else if (z==11 && s<=6570)
  {
  x="-6140-Y11";
  }
else if (z==11 && s<=7650)
  {
  x="-6145-Y11";
  }
else if (z==11 && s<=9900)
  {
  x="-6160-Y11";
  }
else if (z==17 && s<=408)
  {
  x="-6080-Y17";
  }
else if (z==17 && s<=536)
  {
  x="-6085-Y17";
  }
else if (z==17 && s<=788)
  {
  x="-6090-Y17";
  }
else if (z==17 && s<=1040)
  {
  x="-6095-Y17";
  }
else if (z==17 && s<=1620)
  {
  x="-6100-Y17";
  }
else if (z==17 && s<=2190)
  {
  x="-6105-Y17";
  }
else if (z==17 && s<=2440)
  {
  x="-6110-Y17";
  }
else if (z==17 && s<=2680)
  {
  x="-6115-Y17";
  }
else if (z==17 && s<=3490)
  {
  x="-6120-Y17";
  }
else if (z==17 && s<=4070)
  {
  x="-6125-Y17";
  }
else if (z==17 && s<=5360)
  {
  x="-6130-Y17";
  }
else if (z==17  && s<=6160)
  {
  x="-6135-Y17"
  }
else if (z==17  && s<=8250)
  {
  x="-6140-Y17"
  }
else if (z==17  && s<=9370)
  {
  x="-6145-Y17"
  }
else if (z==17  && s<=10200)
  {
  x="-6160-Y17"
  }
else if (z==17  && s<=14700)
  {
  x="-6165-Y17"
  }
else if (z==29 && s<=621)
  {
  x="-6085-Y29";
  }
else if (z==29 && s<=832)
  {
  x="-6090-Y29";
  }
else if (z==29 && s<=1040)
  {
  x="-6095-29";
  }
else if (z==29 && s<=1610)
  {
  x="-6100-Y29";
  }
else if (z==29 && s<=2120)
  {
  x="-6105-Y29";
  }
else if (z==29 && s<=2530)
  {
  x="-6110-29";
  }
else if (z==29 && s<=2950)
  {
  x="-6115-Y29";
  }
else if (z==29 && s<=3980)
  {
  x="-6120-Y29";
  }
else if (z==29 && s<=5010)
  {
  x="-6125-29";
  }
else if (z==29 && s<=5960)
  {
  x="-6130-Y29";
  }
else if (z==29 && s<=7500)
  {
  x="-6135-Y29";
  }
else if (z==29 && s<=7920)
  {
  x="-6140-29";
  }
else if (z==29 && s<=9980)
  {
  x="-6145-Y29";
  }
else if (z==29 && s<=14000)
  {
  x="-6160-Y29";
  }
else if (z==29 && s<=15200)
  {
  x="-6165-29";
  }
else if (z==29 && s<=19000)
  {
  x="-6170-Y29";
  }
else if (z==29 && s<=25000)
  {
  x="-6175-Y29";
  }
else if (z==35 && s<=981)
  {
  x="-6090-Y35";
  }
else if (z==35 && s<=1220)
  {
  x="-6095-Y35";
  }
else if (z==35 && s<=1560)
  {
  x="-6100-Y35";
  }
else if (z==35 && s<=1920)
  {
  x="-6105-Y35";
  }
else if (z==35 && s<=2410)
  {
  x="-6110-Y35";
  }
else if (z==35 && s<=2900)
  {
  x="-6115-Y35";
  }
else if (z==35 && s<=4010)
  {
  x="-6120-Y35";
  }
else if (z==35 && s<=5100)
  {
  x="-6125-Y35";
  }
else if (z==35 && s<=5950)
  {
  x="-6130-Y35";
  }
else if (z==35 && s<=6820)
  {
  x="-6135-Y35";
  }
else if (z==35 && s<=8360)
  {
  x="-6140-Y35";
  }
else if (z==35 && s<=12200)
  {
  x="-6145-Y35";
  }
else if (z==35 && s<=15500)
  {
  x="-6160-Y35";
  }
else if (z==35 && s<=18300)
  {
  x="-6165-Y35";
  }
else if (z==35 && s<=19300)
  {
  x="-6170-Y35";
  }
else if (z==35 && s<=24100)
  {
  x="-6175-Y35";
  }
else if (z==35 && s<=30200)
  {
  x="-6180-Y35";
  }
else if (z==43 && s<=858)
  {
  x="-6090-Y43";
  }
else if (z==43 && s<=1190)
  {
  x="-6095-Y43";
  }
else if (z==43 && s<=1540)
  {
  x="-6100-Y43";
  }
else if (z==43 && s<=2140)
  {
  x="-6105-Y43";
  }
else if (z==43 && s<=2570)
  {
  x="-6110-Y43";
  }
else if (z==43 && s<=2990)
  {
  x="-6115-Y43";
  }
else if (z==43 && s<=3780)
  {
  x="-6120-Y43";
  }
else if (z==43 && s<=4700)
  {
  x="-6125-Y43";
  }
else if (z==43 && s<=5910)
  {
  x="-6130-Y43";
  }
else if (z==43 && s<=7430)
  {
  x="-6135-Y43";
  }
else if (z==43 && s<=7780)
  {
  x="-6140-Y43";
  }
else if (z==43 && s<=10600)
  {
  x="-6145-Y43";
  }
else if (z==43 && s<=14700)
  {
  x="-6160-Y43";
  }
else if (z==43 && s<=15500)
  {
  x="-6165-Y43";
  }
else if (z==43 && s<=19200)
  {
  x="-6170-Y43";
  }
else if (z==43 && s<=22300)
  {
  x="-6175-Y43";
  }
else if (z==43 && s<=29800)
  {
  x="-6180-Y43";
  }
else if (z==43 && s<=37200)
  {
  x="-6185-Y43";
  }
else if (z==59 && s<=1010)
  {
  x="-6095-Y59";
  }
else if (z==59 && s<=1400)
  {
  x="-6100-Y59";
  }
else if (z==59 && s<=1920)
  {
  x="-6105-Y59";
  }
else if (z==59 && s<=2330)
  {
  x="-6110-Y59";
  }
else if (z==59 && s<=2730)
  {
  x="-6115-Y59";
  }
else if (z==59 && s<=3530)
  {
  x="-6120-Y59";
  }
else if (z==59 && s<=4380)
  {
  x="-6125-Y59";
  }
else if (z==59 && s<=5920)
  {
  x="-6130-Y59";
  }
else if (z==59 && s<=6830)
  {
  x="-6135-Y59";
  }
else if (z==59 && s<=8010)
  {
  x="-6140-Y59";
  }
else if (z==59 && s<=9900)
  {
  x="-6145-Y59";
  }
else if (z==59 && s<=12000)
  {
  x="-6160-Y59";
  }
else if (z==59 && s<=15500)
  {
  x="-6165-Y59";
  }
else if (z==59 && s<=19400)
  {
  x="-6170-Y59";
  }
else if (z==59 && s<=25500)
  {
  x="-6175-Y59";
  }
else if (z==59 && s<=26400)
  {
  x="-6180-Y59";
  }
else if (z==59 && s<=32500)
  {
  x="-6185-Y59";
  }
else if (z==59 && s<=41300)
  {
  x="-6190-Y59";
  }
else if (z==59 && s<=51000)
  {
  x="-6195-Y59";
  }
else if (z==71 && s<=1410)
  {
  x="-6100-Y71";
  }
else if (z==71 && s<=1830)
  {
  x="-6105-Y71";
  }
else if (z==71 && s<=2180)
  {
  x="-6110-Y71";
  }
else if (z==71 && s<=2470)
  {
  x="-6115-Y71";
  }
else if (z==71 && s<=3120)
  {
  x="-6120-Y71";
  }
else if (z==71 && s<=3910)
  {
  x="-6125-Y71";
  }
else if (z==71 && s<=5960)
  {
  x="-6130-Y71";
  }
else if (z==71 && s<=7070)
  {
  x="-6135-Y71";
  }
else if (z==71 && s<=7920)
  {
  x="-6140-Y71";
  }
else if (z==71 && s<=9810)
  {
  x="-6145-Y71";
  }
else if (z==71 && s<=11300)
  {
  x="-6160-Y71";
  }
else if (z==71 && s<=18400)
  {
  x="-6165-Y71";
  }
else if (z==71 && s<=19300)
  {
  x="-6170-Y71";
  }
else if (z==71 && s<=23300)
  {
  x="-6175-Y71";
  }
else if (z==71 && s<=28600)
  {
  x="-6180-Y71";
  }
else if (z==71 && s<=31900)
  {
  x="-6185-Y71";
  }
else if (z==71 && s<=44100)
  {
  x="-6190-Y71";
  }
else if (z==71 && s<=50800)
  {
  x="-6195-Y71";
  }
else if (z==87 && s<=1730)
  {
  x="-6100-Y87";
  }
else if (z==87 && s<=2260)
  {
  x="-6105-Y87";
  }
else if (z==87 && s<=2640)
  {
  x="-6110-Y87";
  }
else if (z==87 && s<=3030)
  {
  x="-6115-Y87";
  }
else if (z==87 && s<=3770)
  {
  x="-6120-Y87";
  }
else if (z==87 && s<=4510)
  {
  x="-6125-Y87";
  }
else if (z==87 && s<=5660)
  {
  x="-6130-Y87";
  }
else if (z==87 && s<=7620)
  {
  x="-6135-Y87";
  }
else if (z==87 && s<=7900)
  {
  x="-6140-Y87";
  }
else if (z==87 && s<=9900)
  {
  x="-6145-Y87";
  }
else if (z==87 && s<=13900)
  {
  x="-6160-Y87";
  }
else if (z==87 && s<=15500)
  {
  x="-6165-Y87";
  }
else if (z==87 && s<=19200)
  {
  x="-6170-Y87";
  }
else if (z==87 && s<=22500)
  {
  x="-6175-Y87";
  }
else if (z==87 && s<=28500)
  {
  x="-6180-Y87";
  }
else if (z==87 && s<=34200)
  {
  x="-6185-Y87";
  }
else if (z==87 && s<=47000)
  {
  x="-6190-Y87";
  }
else if (z==87 && s<=54400)
  {
  x="-6195-Y87";
  }
else if (z==87 && s<=63500)
  {
  x="-6205-Y87";
  }
else if (z==87 && s<=85400)
  {
  x="-6215-Y87";
  }
else
  {
  x="- stop and contact Jay at 601.583.2005"
  }
document.getElementById("resulta").innerHTML= o + x + m;
document.getElementById('resultb').innerHTML = Math.round(r) + " RPM";
document.getElementById("resultc").innerHTML= s;
document.getElementById("resultd").innerHTML= n;

}
</script>
Use this application at your own risk. Results are calculated based on the Cyclo 6000 series catalog information.  The information provided is for reference ONLY!! I do not make any claims the information is correct, viable, usable, safe or marketable.  YOU are responsible for insuring YOU select the correct speed reducer based on the literature and guidance of Sumitomo Machinery Corporation of America (or Japan)!

</center>
<div>
</body>
</html>

这很棒,除了我在该方法上投入了 100 个小时,而且我需要再做 5-6 个制造商,这些制造商将比我刚刚做的更大。这只是一家制造商的一条生产线,我将其截断,仅证明他们提供的 18 种可能比率中的 8 种,从而将工作量减少一半...

我想要做的是为每个齿轮线创建一个 2 列表(如开头的示例),并让计算机查看第 1 列以在第 1 列中查找大于“的值” s”(行#x,列#1)但小于下一行(行#y,列#1)中的“s”,并打印行#y列#2的数据。

似乎有一个简单的答案,但我找不到它——grep,awk,sed,一些东西,但我错过了......

最佳答案

这在 Awk 中很简单。传入您想要比较的值(您可能会将其放在 shell 变量中,但在本示例中,我硬编码 203),然后从最后一行返回第二列,其中该值等于或大于第一列中的数字。

awk -F : -v value="203" 'NR==1 { next }  # skip the silly header line
    value >= $1 { m=$2; next }
    { exit }  # done; fall through to END
    END { print m }' file

这显然假设输入文件在第一列上按单调递增顺序排序,如您的示例所示。

-F : 设置列分隔符(Awk 中的默认值是任意空格),-v value=whatever 设置 Awk 变量 value 到任何地方。 (一个常见的新手误解是假设 shell 变量对 Awk 可用,但事实并非如此。awk 基本上对调用程序一无所知,甚至不能假设它首先是从 shell 调用的。)

主要逻辑应该很容易理解 - awk 一次读取一行,并将 m 设置为第二列,只要该值大于或等于第一列的数字列,然后跳过脚本的其余部分,并从内存中的下一个输入行开始再次继续。当条件不再成立时,我们就退出;当脚本退出时,我们打印从上一行捕获的值。 (退出是这里的一个小优化;显然不需要读取文件的其余部分。)作为几个极端情况,我们跳过第一行(因为它包含标题,而不是实际数据)并应对脱落通过从 END block 进行打印来结束文件末尾,而不是仅在我们实际遇到第一列实际上大于输入值的行时才打印并退出。

如果您在 shell 脚本中需要此功能,则仅获取变量中的输出值的构造是

outputvalue=$(awk -F : -v value="$inputvalue" ....)

同样的逻辑显然也很容易在 Python 中实现。

import logging, sys

try:
    value = int(sys.argv[1])
except IndexError:
    logging.error('Syntax: {0} value'.format(sys.argv[0]))
    exit(123)

final = None
for line in sys.stdin:
    line = line.rstrip('\n')
    try:
        first, second = line.split(':')
    except ValueError:
        logging.warn('Invalid input {0}'.format(line))
        continue
    first = int(first)
    if value >= first:
        final = second
    else:
        break
print(final)
<小时/>

最后,这是 Javascript 代码的重构版本,(我希望)它可以用更少的代码完成基本相同的事情。我并不是一个真正的 JavaScript 程序员,我也没有尝试过多地清理代码,但我猜这样的东西就是您实际上想要的。

function sumisize()
{
var y = (document.getElementById('vara').value);
var v = (document.getElementById('varb').value);
var u = (document.getElementById('varc').value);
var q = (document.getElementById('vard').value);
var w=(v*36);
var t=(w*u);
var s=(t*y);
var r=((1750/u)/y);
var x="";
var z=(y);
var p=(q);
var o="";
var n="";
var m="";

var zvalues = {
    11: { 298: 6080,   393: 6085,   579: 6090,   765: 6095,  1190: 6100,
	 1610: 6105,  1790: 6110,  1970: 6115,  2560: 6120,  2990: 6125,
	 4730: 6130,  5700: 6135,  6570: 6140,  7650: 6145,  9900: 6160 },
    17: { 408: 6080,   536: 6085,   788: 6090,  1040: 6095,  1620: 6100,
	 2190: 6105,  2440: 6110,  2680: 6115,  3490: 6120,  4070: 6125,
         5360: 6130,  6160: 6135,  8250: 6140,  9370: 6145, 10200: 6160,
	14700: 6165 },
    29: { 621: 6085,   832: 6090,  1040: 6095,  1610: 6100,  2120: 6105,
	 2530: 6110,  2950: 6115,  3980: 6120,  5010: 6125,  5960: 6130,
	 7500: 6135,  7920: 6140,  9980: 6145, 14000: 6160, 15200: 6165,
	19000: 6170, 25000: 6175 },
    35: { 981: 6090,  1220: 6095,  1560: 6100,  1920: 6105,  2410: 6110,
	 2900: 6115,  4010: 6120,  5100: 6125,  5950: 6130,  6820: 6135,
	 8360: 6140, 12200: 6145, 15500: 6160, 18300: 6165, 19300: 6170,
	24100: 6175, 30200: 6180 },
    43: { 858: 6090,  1190: 6095,  1540: 6100,  2140: 6105,  2570: 6110,
	 2990: 6115,  3780: 6120,  4700: 6125,	5910: 6130,  7430: 6135,
	 7780: 6140, 10600: 6145, 14700: 6160, 15500: 6165, 19200: 6170,
	22300: 6175, 29800: 6180, 37200: 6185 },
    59: {1010: 6095,  1400: 6100,  1920: 6105,  2330: 6110,  2730: 6115,
	 3530: 6120,  4380: 6125,  5920: 6130,  6830: 6135,  8010: 6140,
	 9900: 6145, 12000: 6160, 15500: 6165, 19400: 6170, 25500: 6175,
	26400: 6180, 32500: 6185, 41300: 6190, 51000: 6195 },
    71: {1410: 6100,  1830: 6105,  2180: 6110,	2470: 6115,  3120: 6120,
	 3910: 6125,  5960: 6130,  7070: 6135,  7920: 6140,  9810: 6145,
	11300: 6160, 18400: 6165, 19300: 6170, 23300: 6175, 28600: 6180,
	31900: 6185, 44100: 6190, 50800: 6195 },
    87: {1730: 6100,  2260: 6105,  2640: 6110,  3030: 6115,  3770: 6120,
	 4510: 6125,  5660: 6130,  7620: 6135,  7900: 6140,  9900: 6145,
	13900: 6160, 15500: 6165, 19200: 6170, 22500: 6175, 28500: 6180,
	34200: 6185, 47000: 6190, 54400: 6195, 63500: 6205, 85400: 6215 }
};

var mvalues = { 0.5:  -56,  1.0: -143,  1.5: -145,  2.0: -145,  3.0: -182,
		5.0: -184,  7.5: -213, 10.0: -215, 15.0: -254, 20.0: -256 };

if (p>0) {
    m=mvalues[v];
}

if (p==0)
  {
  o="CHH";
  }
else if (p==1)
  {
  o="CHHP";
  }
else if (p==2 && u==1)
  {
  o="CHHJ";
  }
else 
  {
  n=" Please Set 'Belt Drive Ratio' to 1 ";
  }
 
    var smax = -1;
    var diag = "diagnostics: "
    for (var k in zvalues[z]) {
	diag += "k(" + k + ")<=s(" + s + ")? "
	if (k<=s && k>smax) {
	    diag += "k>smax(" + smax + "); dv=" + zvalues[z][k] + ". "
	      smax = k;
	      dv = zvalues[z][k];
	  }
    }
    diag += " Final smax = " + smax
    if (smax > -1)
    {
	x="-" + dv + "-Y" + z;
    }
else
  {
  x="- stop and contact Jay at 601.583.2005" + diag
  }
document.getElementById("resulta").innerHTML= o + x + m;
document.getElementById('resultb').innerHTML = Math.round(r) + " RPM";
document.getElementById("resultc").innerHTML= s;
document.getElementById("resultd").innerHTML= n;

}
body {
    background-image: url("../media/sumi.jpeg");
    background-repeat: no-repeat;
    background-position: right top;
}
#main {
  max-width: 800px;
  margin: 20px auto; 
  border: solid;
  background: #87CEEB;
  padding: 50px;
  position: relative; 
}
/*
#answer {
  max-width: 200px;
  margin: 20px auto; 
  border: solid;
  background: #FFEFD5;
  padding: 50px;
  position: relative;
  padding: 10px;
  right: 300px; 
}*/
<!DOCTYPE html>
<html lang="en">
<body>
<head>
    <meta charset="utf-8">
    <title>Sumitomo Sizer</title><br>
</head>
<body>
<h6> here it is:
<h1><b>Sumitomo Cyclo sizer!!</b></h1>
<div id="main">
<P> I am only showing 8 of the 18 available ratios.  Sure, you might need       the others for some reason, but you can do most things with these 8.</p>

<p>  What output speed is closest AND OVER what you need:
  <select id="vara">
<option value="11">159 RPM (11:1)</option>
<option value="17">103 RPM (17:1)</option>
<option value="29">60 RPM (29:1)</option>
<option value="35">50 RPM (35:1)</option>
<option value="43">40 RPM (43:1)</option>
<option value="59">30 RPM (59:1</option>
<option value="71">25 RPM (71:1)</option>
<option value="87">20 RPM (87:1)</option>
</select>
</p>

<P>What is your motor Horsepower @1750:
   <select id="varb">
<option value="0.5">1/2</option>
<option value="1">1</option>
<option value="1.5">1-1/2</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="5">5</option>
<option value="7.5">7.5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
</select>
</p>
<p>belt drive ratio: 
<input id="varc" type="text" value="1"/>:1
</p>
<P>Input style:
   <select id="vard">
<option value="0">Standard</option>
<option value="1">Top motor mount</option>
<option value="2">C-face (w/coupling)</option>
</select>
</p>
<p>Click the button to get your Sumitomo size</p>

<button onclick="sumisize()">Find it</button>
</p>
<div id="answer">
Sumitomo part number: <h2><p id="resultd"></h2></p><p id="resulta"></p>
Actual output speed: <p id="resultb"> </p>
Torque in inch-lbs.:<p id="resultc"></p>
</div>

Use this application at your own risk. Results are calculated based on the Cyclo 6000 series catalog information.  The information provided is for reference ONLY!! I do not make any claims the information is correct, viable, usable, safe or marketable.  YOU are responsible for insuring YOU select the correct speed reducer based on the literature and guidance of Sumitomo Machinery Corporation of America (or Japan)!

</center>
<div>
</body>
</html>

关于python - 在表中搜索第 1 列中的值并打印同一行第 2 列中的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46542979/

相关文章:

python - 使用 flask 获取输入文件名和文件扩展名

android - 如何使用 kivy buildozer 压缩 Apk?

python - 列表理解以展平字典的字典

MySQL 表关系 - 如果字段有值则加入

mysql - 如果另一种语言为空,请选择一种语言的值

python - 在 Mysql 或 Python 中良好的实现,可以增加有限的值集

php - PHP 和 MYSQL 中的 IM 聊天系统?

linux - 为 bash 编写脚本时遇到问题

bash - 有没有等同于 bash 的 '!$' 的 vim?

bash - 将 PSQL 添加到 .bash_profile mac