所以我的问题是让用户输入数小时的更短的方法,而不是我制作一个巨大的单词列表,说明用户输入1是否使其成为“一个”等。我觉得我应该使用pop但同时,我觉得我怎样才能获得用户输入以从列表中获取某个单词。
-- table definition
create table Particle_counter_HiSam ( time_utc timestamp, ... );
-- load data
load data infile 'data.csv'
into table Particle_counter_HiSam
fields terminated BY ',' ESCAPED BY ""
lines terminated by '\r\n'
(@var1, c2, ....)
SET time_utc = STR_TO_DATE(@var1,'%m/%d/%Y %H:%i:%S');
答案 0 :(得分:1)
将输入转换为整数,然后使用它们索引已有的数组。简化示例:
hours = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve"]
hour = int(input("Please enter the hour: "))
print(hours[hour-1] + " O'clock")
# Subtract one from hour because arrays start at index 0 but hours starts at "one"