我有import csv
import os
import subprocess
def callGetDimmBatchFile(goodFile, badFile, logFile, batchFileName, ipAddress, userName, passWord):
command ='{0} -i {1} -u {2} -p {3}'.format(batchFileName, ipAddress, userName, passWord)
print(command)
logFile.write(command + '\n')
logFile.flush()
p = subprocess.Popen(command)
output = p.communicate()
logFile.write('{0}'.format(output) + '\n')
logFile.flush()
goodFile = open('good.txt', 'w+')
badFile = open('bad.txt', 'w+')
logFile = open('log.txt', 'w+')
batchFileName = 'getdimm.bat'
pathToCsv = 'autorun-input.csv'
print('Path to CSV is {0}'.format(pathToCsv))
counter = 0
with open(pathToCsv) as csvFile:
reader = csv.reader(csvFile, delimiter=',')
for row in reader:
ipAddress = row[0]
userName = row[1]
passWord = row[2]
counter += 1
print(counter)
logFile.write('{0}'.format(counter) + '\n')
logFile.flush()
callGetDimmBatchFile(goodFile, badFile, logFile, batchFileName, ipAddress, userName, passWord)
os.system("pause")
,我想要BYTE bMins = 36;
和bMin1 = 3;
没有长开关等可能吗?
我已经用bMin2 = 6;
尝试了,但这很慢。
答案 0 :(得分:5)
整数除法和模数帮助:
setTimeout(function(){
$("audio").prop('muted', false);
}, 10000);
答案 1 :(得分:1)
这是一个示范程序
#include <iostream>
#include <cstdlib>
int main()
{
typedef unsigned char BYTE;
BYTE bMins = 36;
BYTE bMin1, bMin2;
auto d = std::div( bMins, 10 );
bMin1 = d.quot;
bMin2 = d.rem;
std::cout << "bMin1 = " << ( int )bMin1 << ", bMin2 = " << ( int )bMin2 << std::endl;
}
程序输出
bMin1 = 3, bMin2 = 6
答案 2 :(得分:0)
另一种方法是转换为字符串并使用数字字符:
BYTE bMins = 36;
std::string s = std::to_string(bMins);
BYTE bMin1 = s[0] - '0';
BYTE bMin2 = s[1] - '0';