python创建一个全为1的数据文件【原创】
2022/2/3 20:13:17
本文主要是介绍python创建一个全为1的数据文件【原创】,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
linux 下创建一个全为1的数据文件
touch m.py
import struct cnt = 128 data = [0xFF] with open('data', 'wb+') as fp: while cnt > 0: a = struct.pack('B', *data) fp.write(a) cnt = cnt - 1 print "bye!"
运行
python my.py
sky@sky-virtual-machine:$ file data
data: ISO-8859 text, with no line terminators
sky@sky-virtual-machine:$ xxd data
00000000: ffff ffff ffff ffff ffff ffff ffff ffff ................
00000010: ffff ffff ffff ffff ffff ffff ffff ffff ................
00000020: ffff ffff ffff ffff ffff ffff ffff ffff ................
00000030: ffff ffff ffff ffff ffff ffff ffff ffff ................
00000040: ffff ffff ffff ffff ffff ffff ffff ffff ................
00000050: ffff ffff ffff ffff ffff ffff ffff ffff ................
00000060: ffff ffff ffff ffff ffff ffff ffff ffff ................
00000070: ffff ffff ffff ffff ffff ffff ffff ffff ................
sky@sky-virtual-machine:$ xxd -b data
00000000: 11111111 11111111 11111111 11111111 11111111 11111111 ......
00000006: 11111111 11111111 11111111 11111111 11111111 11111111 ......
0000000c: 11111111 11111111 11111111 11111111 11111111 11111111 ......
00000012: 11111111 11111111 11111111 11111111 11111111 11111111 ......
00000018: 11111111 11111111 11111111 11111111 11111111 11111111 ......
0000001e: 11111111 11111111 11111111 11111111 11111111 11111111 ......
00000024: 11111111 11111111 11111111 11111111 11111111 11111111 ......
0000002a: 11111111 11111111 11111111 11111111 11111111 11111111 ......
00000030: 11111111 11111111 11111111 11111111 11111111 11111111 ......
00000036: 11111111 11111111 11111111 11111111 11111111 11111111 ......
0000003c: 11111111 11111111 11111111 11111111 11111111 11111111 ......
00000042: 11111111 11111111 11111111 11111111 11111111 11111111 ......
00000048: 11111111 11111111 11111111 11111111 11111111 11111111 ......
0000004e: 11111111 11111111 11111111 11111111 11111111 11111111 ......
00000054: 11111111 11111111 11111111 11111111 11111111 11111111 ......
0000005a: 11111111 11111111 11111111 11111111 11111111 11111111 ......
00000060: 11111111 11111111 11111111 11111111 11111111 11111111 ......
00000066: 11111111 11111111 11111111 11111111 11111111 11111111 ......
0000006c: 11111111 11111111 11111111 11111111 11111111 11111111 ......
00000072: 11111111 11111111 11111111 11111111 11111111 11111111 ......
00000078: 11111111 11111111 11111111 11111111 11111111 11111111 ......
0000007e: 11111111 11111111 ..
这篇关于python创建一个全为1的数据文件【原创】的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-08有遇到过吗?同样的规则 Excel 中 比Python 结果大
- 2024-03-30开始python成长之路
- 2024-03-29python optparse
- 2024-03-29python map 函数
- 2024-03-20invalid format specifier python
- 2024-03-18pool.map python
- 2024-03-18threads in python
- 2024-03-14python Ai 应用开发基础训练,字符串,字典,文件
- 2024-03-13id3 algorithm python
- 2024-03-13sum array elements python