不多说了直接上代码
file = open("temp.txt","r")
for line in file:
print line
readFile(file)
def readFile(file):
print file.readline()
这是一段极其简单的代码,但是在运行的过程中却出现“mixing iteration and read methods would lose data python”的错误。由报错信息可知是因为多迭代器的原因导致数据泄漏的危险。由上面的代码可以看出唯一可以出现迭代器的也只有
for line in file
这句话了。所以做如下修改,避免出现多迭代器的问题:
while line !="EOF": #"EOF" 为文件结束标志
line = file.readline()
print line
readFile(file)
def readFile(file):
print file.readline()
问题即可解决。
分享到:
相关推荐
Survey Image Mixing and Deleting for Data Augmentation.pdf
Survey Image Mixing and Deleting for Data Augmentation.zip
Handbook of industrial mixing - science and practice 工业混合手册
We added three new chapters: Chapter 22 on monotone chains, Chapter 23 on the exclusion process, and Chapter 24 that relates mixing times and hitting time parameters to stationary stopping times....
Chapter 8, Data in and Data Out: This chapter starts with basic storing and retrieving of files to a hard drive and progresses to the construction of programs that are tools for creating, storing, ...
mixing jstl and jsf in web applications
Mixing Native and Managed Types in C++.docx
Explore various concrete examples by mixing data and algorithms to discover the things we don’t know that we don’t know Apply Machine Learning algorithms to different kinds of data such as social ...
Easy to understand and fun to read, Introducing Python is ideal for beginning programmers as well as those new to the language. Author Bill Lubanovic takes you from the basics to more involved and ...
Markov Chains and Mixing Times David A. Levin Yuval Peres Elizabeth L. Wilmer
Mixing C and Java™ for High Performance Computing
codec 8388的datasheet资料。 • 24-bit, 8 kHz to 96 kHz sampling frequency • 95 dB dynamic range, 95 dB signal to noise ratio, -85 dB THD+N • Stereo or mono microphone interface with microphone ...
Use one programming paradigm instead of mixing and matching tools like Hive, Hadoop, Mahout, and Storm Learn how to deploy interactive, batch, and streaming applications Connect to data sources ...
In PWM Control mode, the PWM duty cycle of each output can be independently programmed and controlled in 256 steps to simplify color mixing. In One Shot Programming mode, the timing characteristics ...
大牛Newman的经典论文,做网络分析的朋友可以参考一下。
The text covers power distribution in facilities, mixing of analog and digital circuitry, circuit board layout at high clock rates, and meeting radiation and susceptibility standards. The author ...
Video Mixing Renderer(VMR)技术
Java code for mixing up RGB color and moving of line
外来植物薇甘菊入侵的凋落物混合分解效应研究,陈宝明,彭少麟,不同植物的凋落物混合后会产生混合分解效应,也称作非加和效应(non-additive effects),有的研究发现不同植物的凋落物混合后会产生正分�