python读取txt⽂件⼀⾏-Python三种读取txt⽂件⽅式# -*- coding: utf-8 -*-
file =open('/Users/april_chou/Desktop/WorkSpace/Selenium/','r')
context = ad()
print('read格式:')
print(context)
file.close()
print()
file =open('/Users/april_chou/Desktop/WorkSpace/Selenium/','r')
context = adlines()
contextLines =''
for i in context:
python怎么读取txt
contextLines = contextLines + i
print('readlines格式:')
print(contextLines)
file.close()
print()
file =open('/Users/april_chou/Desktop/WorkSpace/Selenium/','r')
contextLines =''
while True:
context = adline()
contextLines = contextLines + context
if len(context) ==0:
break
print('readline格式:')
print(contextLines)
file.close()

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。