-4

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

Melebius
  • 5,590
  • 3
  • 34
  • 46
yugahang
  • 19
  • 2

1 Answers1

0

Have you tried something like:

a = ‘07:05:45PM‘
b = [a[:-2], a[-2:]]
S3DEV
  • 6,600
  • 3
  • 24
  • 36
  • 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