title: How can I retrieve a packet payload as a bytearray in Scapy?
body: <p>I have some code that attempts to extract packet payload as a bytearray, by getting the string value from the packet (I believe it returns a bytestring, as a string). How can I just get the raw payload as a bytearray?</p>
  
  <pre><code>packets = rdpcap(pcapFile)
  p = packets[0]
  
  if TCP in p:
      pdata = str(p[TCP].payload)
  elif Raw in p:
      pdata = str(p[Raw].load)
  elif TLS in p:
      pdata = str(p[TLS].msg)
  else:
      pdata = ""
  </code></pre>
  
  <p>When I print pdata, it looks like this</p>
  
  <pre><code>b'\x17\x03\x01\x00 a\xb9j\x17#\xb9uX\xdf\xe3\x08\xe0\xbc\xc3\xce\xa2=\xda\xc9\xd7\x1d7*\xad\xc9Y\xcer1\xdc\xb2\xd1\x17\x03\x01\x00 
  </code></pre>
  
  <p>But it seems that, that is a string, not a bytestring, ad pdata[0] returns <code>'b'</code></p>
  
  <p>How can I get the "payload" as <code>bytes</code> or <code>bytearray</code>?</p>