小知识点
1. 打开文件简化版
f = open('abc.txt','a')
a = f.read()
f.close()
可改写为:
with open('abc.txt','a') as f:
a = f.read()
2. 声明运行环境,应放在程序文件的开头
#! /usr/bin/env python
# -*- coding:utf-8 -*-
# Author:qpzm
f = open('abc.txt','a')
a = f.read()
f.close()
可改写为:
with open('abc.txt','a') as f:
a = f.read()
#! /usr/bin/env python
# -*- coding:utf-8 -*-
# Author:qpzm