摘要:
# 将【日期】列由字符串格式转换为日期格式def time_trans(date): a = datetime.datetime.strptime(date, '%Y-%m-%d') return atime1 = list(map(time_trans, values['日期'].tolist() 阅读全文
摘要:
def numsum(s): sum = 0 # 定义变量,准备记录数字的和 for i in range(len(s)): # 遍历字符串 try: sum = sum + float(s[i]) # 将字符转成int,求和 except: continue return sumnum(s=[1, 阅读全文
摘要:
对字符串直接比大小,有时会出现错误情况,比如: print('2020-8-11' < '2020-8-7')-->True于是就必须将字符串转换为日期格式 import datetimetime1 = datetime.datetime.strptime('2020-8-11', '%Y-%m-% 阅读全文