我正在 Python 2.7 中编写提示参数,以便使用命令行界面导入我的数据文件。
REFERENCE = raw_input("Reference (*.shp):")
SEGMENTED = raw_input("Segmented (*.shp):")
METHOD = raw_input("Method (ke, pu, clinton):")
if METHOD != "ke" and METHOD != "pu" and METHOD != "clinton":
raise ValueError("%s is not a valid method" % METHOD)
if METHOD == "ke" or METHOD == "clinton":
THRESHOLD = input("Threshold (0.0 - 1.0):")
if not check_threshold(THRESHOLD):
raise AccuracyException("Threshold of %s is not valid" % THRESHOLD)
else:
THRESHOLD = None
SEP = raw_input("Sep:")
if SEP != "space" and SEP != "tab" and SEP != "comma" and SEP != "colon" and SEP != "semicolon" and SEP != "hyphen" and SEP != "dot":
raise ValueError("%s is not valid" % SEP)
HEADER = raw_input("Header (True/False):")
if HEADER.strip() != "True" and HEADER.strip() != "False":
raise ValueError("%s is not valid" % HEADER)
# output
OUTPUT = raw_input("Output (*.txt):")
加载后我希望从头开始重置,以便在不重新加载 *.py 文件的情况下导入新数据,因为我的目标是使用 py2exe 将 *.py 转换为 *.exe