fork(9) download
  1. >>> import struct
  2. >>> data = struct.pack('>i4sh', 7, 'spam', 8)
  3. Traceback (most recent call last):
  4. File "<pyshell#56>", line 1, in <module>
  5. data = struct.pack('>i4sh', 7, 'spam', 8)
  6. struct.error: argument for 's' must be a bytes object
  7. >>> F = open('data.bin', 'wb')
  8. >>> import struct
  9. >>> data = struct.pack('>i4sh', 7, 'spam', 8)
  10. Traceback (most recent call last):
  11. File "<pyshell#59>", line 1, in <module>
  12. data = struct.pack('>i4sh', 7, 'spam', 8)
  13. struct.error: argument for 's' must be a bytes object
  14. >>> data = struct.pack(r'>i4sh', 7 , r'spam', 8)
  15. Traceback (most recent call last):
  16. File "<pyshell#60>", line 1, in <module>
  17. data = struct.pack(r'>i4sh', 7 , r'spam', 8)
  18. struct.error: argument for 's' must be a bytes object
  19. >>> data = struct.pack('>i4h', 7, 'spam', 8)
  20. Traceback (most recent call last):
  21. File "<pyshell#61>", line 1, in <module>
  22. data = struct.pack('>i4h', 7, 'spam', 8)
  23. struct.error: pack requires exactly 5 arguments
  24. >>> data = struct.pack('>i4h', 7, 1, 'spam', 8)
  25. Traceback (most recent call last):
  26. File "<pyshell#62>", line 1, in <module>
  27. data = struct.pack('>i4h', 7, 1, 'spam', 8)
  28. struct.error: pack requires exactly 5 arguments
  29. >>> data = struct.pack(7, 1, 8)
  30. Traceback (most recent call last):
  31. File "<pyshell#63>", line 1, in <module>
  32. data = struct.pack(7, 1, 8)
  33. TypeError: Struct() argument 1 must be a bytes object, not int
  34. >>> data = struct.pack('spam', 7, 1, 8)
  35. Traceback (most recent call last):
  36. File "<pyshell#64>", line 1, in <module>
  37. data = struct.pack('spam', 7, 1, 8)
  38. struct.error: bad char in struct format
  39. >>> data = struct.pack('>i4')
  40. Traceback (most recent call last):
  41. File "<pyshell#65>", line 1, in <module>
  42. data = struct.pack('>i4')
  43. struct.error: repeat count given without format specifier
  44. >>> data = struct.pack('>i4h')
  45. Traceback (most recent call last):
  46. File "<pyshell#66>", line 1, in <module>
  47. data = struct.pack('>i4h')
  48. struct.error: pack requires exactly 5 arguments
  49. >>> data = struct.pack('>i4h', '>i4h', '>i4h', '>i4h', '>i4h', )
  50. Traceback (most recent call last):
  51. File "<pyshell#67>", line 1, in <module>
  52. data = struct.pack('>i4h', '>i4h', '>i4h', '>i4h', '>i4h', )
  53. struct.error: pack requires exactly 5 arguments
Runtime error #stdin #stdout 0.02s 5760KB
stdin
Standard input is empty
stdout
Standard output is empty