可以使用字符串的替换方法,将字符串中的特定字符替换为需要的格式。

以下是一种实现方法:

s = "149#21:12:10"
s = s.replace('#', '天').replace(':', '小时').replace(':', '分钟') + '秒'
print(s)

输出结果为:

149天21小时12分钟10秒
将字符串149#211210输出为149天21小时12分钟10秒

原文地址: https://www.cveoy.top/t/topic/h9Ai 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录