Python70分WA求帮助
查看原帖
Python70分WA求帮助
999576
Kleeaaaa楼主2024/3/31 11:39
num=list(input())
if num[-1]=='%':
    num.pop()
    percent=''.join(num[::-1]+list('%'))
    print(percent.lstrip('0'))
elif '/' in num:
    sym_location = num.index('/')
    tem_num = num[:sym_location]
    tem_num0 = num[sym_location + 1:]
    fenzi=''.join(tem_num[::-1])
    zi=str(fenzi).lstrip('0')
    fenmu=''.join(tem_num0[::-1])
    mu=str(fenmu).lstrip('0')
    print(zi+'/'+mu)
elif '.' in num:
    sym_location = num.index('.')
    tem_num = num[:sym_location]
    tem_num0 = num[sym_location + 1:]
    xiaoshu = str(''.join(tem_num[::-1] + list('.') + tem_num0[::-1]))
    print(xiaoshu.strip('0'))
else:
    z=str(''.join(num[::-1]))
    print(z.lstrip('0'))

2024/3/31 11:39
加载中...