我是靠谱客的博主 朴素书包,这篇文章主要介绍python中readtext_read content in a text file in python,现在分享给大家,希望可以做个参考。

** read text file in python

capability: reading =text= from a text file

1. open the IDLE text editor

>>> idle3

2. declare a *string* variable that holds *the path to the text file*, =test.txt=

>>> strPath="/home/kaiming/Documents/Python/text/text.dat"

3. open the file using the =open()= function

>>> f=open(strPath)

4. Read the contents of the file using the =read()= function

>>> StrText=f.read()

5. Print out the contents of the file

>>> print(strText)

refer to

https://docs.python.org/2/tutorial/inputoutput.html

最后

以上就是朴素书包最近收集整理的关于python中readtext_read content in a text file in python的全部内容,更多相关python中readtext_read内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(166)

评论列表共有 0 条评论

立即
投稿
返回
顶部