【发布时间】:2016-06-14 00:50:32
【问题描述】:
如何让用户自己命名“copied_holter.ecg”?我提供了该名称,但我希望用户选择他们想要的任何名称。
class MyParser(argparse.ArgumentParser):
def error(self, message):
sys.stderr.write('error: %s\n' % message)
self.print_help()
sys.exit(2)
parser = MyParser(util_help)
parser.add_argument('filename', help='The full path/to/holter_file that you would like to parse.', action="store")
parser.add_argument('packet_start', help='The offset location of the start packet ID in base 10 decimal', action="store", type = int)
parser.add_argument('packet_end', help='The offset location of the end packet ID in base 10 decimal', action = "store", type = int)
parser.add_argument('new_filename', help='The name of the new file with the copied holter data chosen by user.', action = "store")
args = parser.parse_args()
start = args.packet_start
end = args.packet_end
if start % 5 != 0:
start = int(5*round(float(start)/5))
if end % 5 != 0:
end = int(5*round(float(end)/5))
try:
print("Beginning copying of holter data...")
# Output the specific holter data
output_file = open(new_filename+".ecg", 'w')
【问题讨论】:
-
这段代码没有告诉我们任何事情......
标签: python