我正在将一些旧的Ruby脚本翻译成Python,并且无法在Python中找到属于Ruby的函数: http://www.ruby-doc.org/core/classes/Array.src/M002222.html - 它使数组保持小尾数字节顺序。有没有可以帮助我的Python模块?Python等价于Ruby的包函数
2
A
回答
1
Python标准库的array模块可能提供了一些类似的功能(虽然它绝对不是完全匹配)。它不强制排序(可以用方法byteswap
替换项目的排列顺序),并且本质上不会将项目保留为“字符串”(可以使用方法tostring
和fromstring
来回转换),但可能值得一看,具体取决于我想你如何使用Ruby pack
函数。
1
内置的Python memoryview允许您将一个数组或任何类似字节的对象“转换”为不同的字节序。 Se .cast方法。关于memoryviews的好处在于它们在不复制字节的情况下运行:它们与源数据结构共享内存。
相关问题
- 1. python等价于ruby bundler包
- 2. python等价于ruby的__method__?
- 3. python等价于ruby的StringScanner?
- 4. Ruby等价于Python的DictWriter?
- 5. python等价于ruby的`map.with_index`?
- 6. Ruby的等价于PHP的“get_defined_vars”函数?
- 7. Ruby的等价于PHP的ucfirst()函数
- 8. Python的等价于R的logspace_add函数?
- 9. Python中的“require”(Ruby)等价于什么?
- 10. 用于Python的MEX等价物(C包装函数)
- 11. fromCharCode等价于Ruby
- 12. charCodeAt()等价于Ruby
- 13. Python的等价Ruby的'method_missing'
- 14. Ruby的等价的Python setattr()
- 15. Python的等价函数lsqcurvefit()函数
- 16. Ruby的等价PHP的mcrypt_encrypt()函数
- 17. Java等价于ntohll函数
- 18. file_get_contents等价于curl函数
- 19. Fortran等价于numpy.where()函数?
- 20. Dojo等价于jQuery.text函数?
- 21. Ruby ::等价于Tie :: FIle?
- 22. PL/Ruby等价于MySQL
- 23. Python等价于bwmorph
- 24. Python等价于ignoreboth:erasedups
- 25. Python的等价物的MATLAB psf2otf函数
- 26. Matlab imfilter在Python中的等价函数
- 27. python中的perror等价函数
- 28. python等价的perl vec()函数
- 29. python等价于MATLAB的mxCreateDoubleMatrix
- 30. 等价于python“dir”的Java?