如果语句未在我的Python脚本中执行?

时间:2019-01-28 05:19:59

标签: python-3.x

def timeConversion(s):
z = s.split(':')
if 'p' in z[2]:
    print("Hello")
    z[0] = str(int(z[0]) + 12)
    z[2] = z[2][:-2]
    t = (':'.join(str(i) for i in z))
    return(t)
if 'a' in z[2]:
    z[2] = z[2][:-2]
    t = (':'.join(str(i) for i in z))
    return(t)

如果名称 =='主要”:     d = timeConversion('07:05:45PM')     打印(d)

1 个答案:

答案 0 :(得分:1)

def timeConversion(s):
    z = s.split(':')
    if 'P' in z[2]:
        print("Hello")
        z[0] = str(int(z[0]) + 12)
        z[2] = z[2][:-2]
        t = (':'.join(str(i) for i in z))
        return(t)
    if 'A' in z[2]:
        z[2] = z[2][:-2]
        t = (':'.join(str(i) for i in z))
        return(t)
if __name__ == "__main__": 
    d = timeConversion('07:05:45PM') 
    print(d)