cstringio

    1熱度

    3回答

    我想迭代行cStringIO對象,但它似乎不適用於foreach循環。更確切地說,行爲就好像集合是空的。我究竟做錯了什麼? 例如: Python 2.7.12 (default, Aug 29 2016, 16:51:45) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2 Type "help", "copyright", "credits"

    3熱度

    1回答

    如何用StringIO中的另一個替換字符串? - 如果它們的長度相同,我聽說它是​​可能的。 嘗試: from cStringIO import StringIO c = 'can\nhaz\nfoo' sio = StringIO(c) for line in sio: if line == 'haz\n': # sio.write('bar\n')

    2熱度

    1回答

    我運行下面的程序慢17%: import cStringIO import time import threading def func(tid): buff = 'a'*4096 i = 0 while (i < 40000000): output = cStringIO.StringIO() output.write(buff)

    1熱度

    1回答

    StringIO在其代碼如下注意事項: Notes: - Using a real file is often faster (but less convenient). - There's also a much faster implementation in C, called cStringIO, but it's not subclassable. 「真正的文件往往是快

    0熱度

    1回答

    我想寫一個cStringIO緩衝區到磁盤。緩衝區可能代表pdf,圖像或html文件。 我採取的方法似乎有點不可靠,所以我也開放其他方法作爲解決方案。 def copyfile(self, destfilepath): if self.datastream.tell() == 0: raise Exception("Exception: Attempt to copy empt

    3熱度

    1回答

    我寫了一個基準,我比較了不同字符串連接方法ZOCache。 因此,它看起來像這裏是tempfile.TemporaryFile比什麼都更快: $ python src/ZOCache/tmp_benchmark.py 3.00407409668e-05 TemporaryFile 0.385630846024 SpooledTemporaryFile 0.299962997437 Buffe

    0熱度

    1回答

    我試圖從URL(由Google的Static Maps API提供)讀取圖像。 圖像在瀏覽器中顯示正常。 ​​3210 https://maps.googleapis.com/maps/api/staticmap?maptype=satellite¢er=37.530101,38.600062&zoom=14&size=256x278&key= ... 但是當我嘗試使用misc.imrea

    1熱度

    1回答

    我有一些問題需要解決。我爲Python 3.2 32bits使用Python 3.2和pyvisa。當我用: import pyvisa 它顯示: ImportError: No module named enum 但是當我使用: import pyqtgraph, pyvisa 我得到: ImportError: No module named cStringIO 我只想用pyv

    0熱度

    1回答

    我知道我可以做一個簡單的內存CSV文件是這樣的: from cStringIO import StringIO tsv_string = '1\t2\t3\n' f = StringIO(tsv_string) 但是我怎麼適應這個包括null/None值?我在問,因爲我正在使用真實數據動態生成我的tsv_string。一些整數字段爲空,我不能用空字符串替換它們,因爲Postgres無法正確

    4熱度

    3回答

    我期待通過StringIO那裏說的來源說一些注意事項: 使用真正的文件往往是速度更快(但不太方便)。 C中還有一個更快的實現,名爲cStringIO,但它不是可以子類化的。 StringIO就像一個內存文件對象, 爲什麼它不是真正的文件對象慢?