简介
想写一个登录注册的demo,但是以前的demo数据都写在程序里面,每一关掉程序数据就没保存住。。
于是想着写到配置文件里好了
Python自身提供了一个Module – configparser,来进行对配置文件的读写
Configuration file parser.
A configuration file consists of sections, lead by a “[section]” header,
and followed by “name: value” entrie
一、从文件中读取数据
#!/usr/bin/env python
with open('pi') as file_object:
contents = file_object.read()
print(contents)
===================================
3.1415926
5212533
2324255
1、逐行读取
#!/usr/bin/env python
filename = 'pi'
with open(filename) as f
文章目录1.\n 换行命令2.\t tab 对齐3.open 读文件方式4.给文件增加内容5.读取文件内容6.读取文件的一行7.读取文件的所有行
1.\n 换行命令
定义 text 为字符串, 并查看使用 \n 和不适用 \n 的区别:\ntext='This is my first test. This is the second line. This the third '
print(text) # 无换行命令
"""
This is my first test. This is the