擅长:python、mysql、java
<p>如果《纽约时报》总是采用这种格式,那么您可以将《纽约时报》分成若干小节。在</p>
<pre><code>x = "12:30PM"
# Use python's string slicing to split on the last two characters
time, day_half = x[:-2], x[-2:]
# Use python's string.split() function to get the difference between hours and minutes
# Because "11" < "2" for strings, we need to convert them to integers
hour, minute = [int(t) for t in time.split(":")]
# Get the remainder because 12 should actually be 0
hour = hour % 12
# Output it as a tuple, which sorts based on each element from left to right
sortable = (day_half, hour, minute)
#: ("PM", 12, 30)
</code></pre>
<p>总而言之,请使用类似以下内容:</p>
^{pr2}$
<p>如果不能保证两个字母在末尾,或者冒号在中间,那么最好使用Prune建议的库。在</p>