This is a little tricky. First, you need to extract the actual date / time string from your source string, then you need to convert the percent-encoded characters to proper chars, and finally you can parse the time and date from it.
However, the standard library can't handle the full time precision of your data - it accepts a 6 digit microseconds field, not 7 digits. And it doesn't handle single letter timezone codes, you'll need to use a 3rd-party module for that. However, if all of your strings use the 'Z' timezone, that's pretty easy to deal with since that's the UTC zone, i.e., it has zero offset from UTC.
Here's some code that gets close to what you want using datetime.strptime
to do the date / time parsing. It simply ignores the last two chars of the time data and replaces the 'Z' with the 'UTC' timezone string.
BTW, I had to adjust your input string slightly: the string you posted in the question isn't a valid string literal.
from urllib.parse import unquote
from datetime import datetime
mystr = 'W/"datetime\'2017-10-16T20%3A18%3A02.2644265Z\'"'
print('Original:', repr(mystr))
# Split on single-quotes
fields = mystr.split("'")
print('Fields:', fields)
# Convert percent-encoded chars to proper chars
datestr = unquote(fields[1])
print('Date:', datestr)
# Trim the final digit and the time zone letter, replacing it with 'UTC'
datestr = datestr[:-2] + 'UTC'
#Convert to a datetime object
timestamp = datetime.strptime(datestr, '%Y-%m-%dT%H:%M:%S.%f%Z')
print('Timestamp:', timestamp, repr(timestamp))
output
Original: 'W/"datetime\'2017-10-16T20%3A18%3A02.2644265Z\'"'
Fields: ['W/"datetime', '2017-10-16T20%3A18%3A02.2644265Z', '"']
Date: 2017-10-16T20:18:02.2644265Z
Timestamp: 2017-10-16 20:18:02.264426 datetime.datetime(2017, 10, 16, 20, 18, 2, 264426)