1
如何將開始和結束限制爲5的倍數?我需要將偏移範圍限制爲5個字節(5的倍數)。如果偏移範圍無效,我想編碼退出。限制參數和錯誤檢查
start = args.packet_start
end = args.packet_end
try:
print("Beginning copying of holter data...")
# Output the specific holter data
output_file = open("copied_holter.ecg", 'w')
# Read part of holter file into memory
holter = open(args.filename, 'rb')
holter.seek(start)
data = holter.read((end+1)-start)
output_file.write(data)
# Close the file streams
holter.close()
output_file.close()
except Exception as e:
print(e)
print("Exiting program, due to exception.")
exit(1)
print "Finished data copying operations!"