我需要删除这两个数字和冒号示例,下午1:30,但在字符串中保留“pm”。我试过以下操作,但它删除了“pm”。
oldtime = ("1:30 pm") newtime = oldtime.split(":")[0]
最终结果应该是
1 pm