Ben her zaman open
ve io.open
değiştirilebilir olduklarını düşündüm.hata veya özellik: open ve io.open değiştirilemez
import ctypes, io
class POINT(ctypes.Structure):
_fields_ = [("x", ctypes.c_int),("y", ctypes.c_int)]
# THIS WORKS
with open("mypoints.bin", "wb") as f:
for i in range(10):
p = POINT(i,10-i)
print p.x, p.y
f.write(p)
# THIS FAILS
with io.open("mypoints.bin", "wb") as f:
for i in range(10):
p = POINT(i,10-i)
print p.x, p.y
f.write(p)
0 10
Traceback (most recent call last):
File "D:\test.py", line 10, in <module>
f.write(p)
File "c:\Python26\lib\io.py", line 1070, in write
self._write_buf.extend(b)
TypeError: 'POINT' object is not iterable
Not: Bu pasajı inanıyorsanız
Görünüşe değil, ben Evet, bir "böcek", Python 2.6 io.open
hafifçe kırılır var Python 2.6.6
Böcek piton 2.7 giderilmiştir alındığını teyit ediyoruz. Çok teşekkürler. – Alain