python关于BIF、标准库方法使用的注意事项总结
2016-04-12 16:28
696 查看
1.file.readline()
通常情况下,都会返回带有换行符的一个字符串`’XXXX\n’但当最后一句并没有换行符时,返回的字符串并不会带有换行符
因此
file.readline()[:-1]可能会漏掉最后一个有效字符
应使用
file.readline().replace('\n',str())
2.sqlite3
执行数据库的修改操作时,为了提高处理效率,有一个缓存,如果需要及时生效,需要commitimport sqlite3 conn.execute('update account set amount=? where account_id=? ',(6.45e4,account_id)) conn.commit
再区分游标cursor与之的不同
cur=conn.cursor()
cursor用于保存查询获取的结果,进行迭代处理
相关文章推荐
- python pip 安装
- nagios用python实现微信报警
- python 3.x和2.x的区别
- python list常见用法
- python.enumerate() 同时遍历索引+内容
- Python对数据库的增删改查
- 通过vscode执行python程序
- python面对对象编程----------7:callable(类调用)与context(上下文)
- PYTHON-进阶-编码处理小结
- Python的getattr()
- python异常如何全面捕获
- Python学习
- python高速排序
- 保留最后N个元素
- Python modify string in place
- 扩展python
- python中的requests用法简介
- python面对对象编程---------6:抽象基类
- python win32api.ExitWindows() 恶作剧好东西
- Python小程序