-4

How can I split the string '07:05:45PM' into ['07:05:45', 'PM'] in Python?

Melebius
  • 6,183
  • 4
  • 39
  • 52
yugahang
  • 27
  • 4

1 Answers1

0

Have you tried something like:

a = ‘07:05:45PM‘
b = [a[:-2], a[-2:]]
S3DEV
  • 8,768
  • 3
  • 31
  • 42
  • UnicodeEncodeError: 'utf-8' codec can't encode character '\udce2' in position 4: surrogates not allowed – yugahang May 24 '20 at 05:10
  • The time mentioned in OP are all ASCII characters, therefore UTF-8 compatible. What characters are you trying to split? – S3DEV May 24 '20 at 08:40