Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
鉴于此代码:
from datetime import datetime Time = datetime.now() print(Time)
我怎么能只打印最后一个数字?例如。
2013-02-08 15:13:32.150263 打印 3 2013-02-08 15:17:40.759672 打印 2
print str(Time)[-1]会做的伎俩...
print str(Time)[-1]
您可以使用:
print str(Time)[-1:]