상세 컨텐츠

본문 제목

how to use File I/O in Python

개발생활/Python

by 한국인맛집 2018. 12. 18. 13:40

본문

반응형





How to Use File I/O ?





File Read


file = open('fileName.text','r')

// All files Read
file.read()


// line Reading at first
file.readline()

// read line at third
file.readline(3)

// All Read Lines
file.readlines()

file.close()




File Write


file = open('fileName.text','w')

//write file 
file.write('hello World!')

file.write('hello Python')

file.close()

//array write in file file = open('fileName.txt','w') mylist = ['hi', 'koboso','this is python file wirte'] file.writelines(mylist) file.close()

반응형

관련글 더보기