MaxCompute py文件是有什么字符限制吗?[阿里云MaxCompute]

MaxCompute py文件是有什么字符限制吗?my_year = int(y_w.split(‘-‘)[0])写上就报错呢? 空格删了在加上也不行,加上7、8行就报错,删了就运行成功: from odps.udf import annotate import datetime @annotate(“string->string”) class y_w_to_m(object): def evaluate(self,y_w): try: jan4 = datetime.date(2022,1,4) week1 = jan4.isocalendar()[1] first_day = jan4 – datetime.timedelta(days=jan4.isoweekday()-1) if 12 > week1: first_day -= datetime.timedelta(weeks=(12-week1)) return datetime.datetime.strftime(first_day,’%Y%m’) except: return null 这个是可以跑通的,先不管数对不对哈 from odps.udf import annotate import datetime @annotate(“string->string”) class y_w_to_m(object): def evaluate(self,y_w): try: year = int(y_w.split(‘-‘)[0]) week = int(y_w.split(‘-‘)[1]) jan4 = datetime.date(year,1,4) week1 = jan4.isocalendar()[1] first_day = jan4 – datetime.timedelta(days=jan4.isoweekday()-1) if week>week1: first_day-=datetime.timedelta(weeks=(week-week1)) return datetime.datetime.strftime(first_day,’%Y%m’) except: return null 这个就跑不通 select y_w_to_m(‘2023-10’);

「点点赞赏,手留余香」

    还没有人赞赏,快来当第一个赞赏的人吧!
=====这是一个广告位,招租中,联系qq 78315851====