Python学习-14.Python的输入输出(三)
在Python中写文件也是得先打开文件的。
file=open(r'E:\temp\test.txt','a')
file.write('append to file')
file.close()
第一行使用追加模式打开文件,第二行则将内容写入文件,第三行关闭文件。
除了write方法外,还有writelines方法
file=open(r'E:\temp\test.txt','a')
lines=['I\n','am\n','Tom\n']
file.writelines(lines)
file.close()
则,执行后,文件会被追加
I
am
Tom
三行内容。
Python学习-14.Python的输入输出(三)的更多相关文章
- Python学习day09 - Python进阶(3)
figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...
- Python学习day05 - Python基础(3) 格式化输出和基本运算符
figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...
- python学习之环境搭建 输入输出
一 环境搭建: 在安装好python2.7之后就可以利用其命令行和交互式模式进行基本的输入和输出测试了,但这样编码无法保存,所以就需要用到好用的编辑器和环境搭建了,这里用uestdio. 1.1打开u ...
- Python学习之路【第三篇】--集合
语法结构: set1.issubset(set2)判断集合set1是否为set2的子集,返回布尔值. ? 1 2 3 4 5 6 s1 = {'Java', 'PHP', 'Python', 'C++ ...
- Python学习(002)--Python介绍
一. Python介绍 python的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚本解释程序,作为AB ...
- Python学习day07 - Python进阶(1) 内置方法
figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...
- Python学习笔记—Python基础1 介绍、发展史、安装、基本语法
第一周学习笔记: 一.Python介绍 1.Python的创始人为吉多·范罗苏姆.1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚本解释程序,作为ABC语言 ...
- python学习笔记-python程序运行
小白初学python,写下自己的一些想法.大神请忽略. 安装python编辑器,并配置环境(见http://www.cnblogs.com/lynn-li/p/5885001.html中 python ...
- Python学习(一) Python安装配置
我本身是Java程序猿,听说Python很强大,所以准备学习一下Python,虽说语言都是相同的,但java跟python肯定还是有区别的.希望在此记录一下自己的学习过程. 目前,Python分2.X ...
随机推荐
- redis位图
<?php function frstr($str){ return str_pad($str,8,'0',STR_PAD_LEFT); } $php=''; $p= frstr(decbin( ...
- mysql-Innodb事务隔离级别-repeatable read详解(转)
一.事务隔离级别 ANSI/ISO SQL标准定义了4中事务隔离级别:未提交读(read uncommitted),提交读(read committed),重复读(repeatable read),串 ...
- elasticsearch 官方入门 及 API
https://www.elastic.co/guide/en/elasticsearch/reference/current/_basic_concepts.html 入门地址 ElasticSea ...
- Autofac log4net Integration Module
log4net Integration Module While there is no specific assembly for log4net support, you can easily i ...
- springboot 2.0 自动装配原理 以redis为例
当面试管问你springboot 和 普通spring 有什么区别? 您还在回答: 简化了配置 ,内置tomcat 等等 吗 ? 那只是皮毛, 最重要的还是自动化配置.一起来了解一下 第一步: 第二步 ...
- phpstudy操作sql server相关经验
1.去官网http://www.phpstudy.net/下载并安装phpstudy 2.修改php.ini配置文件如下: mssql.secure_connection = onextension= ...
- SpringBoot Session 管理及集群管理
1.配置session的超时时间 : 在application.prooperties中 server.session.timeout = 600 //以秒为单位,默认最少一分钟 2.配置 ...
- PowerDesigner 生成的脚本取掉双引号
建模工具PowerDesigner http://www.cnblogs.com/mcgrady/archive/2013/05/25/3098588.html 默认导出在带双引号,表名称后期使用的时 ...
- 使用phpexcel导出到xls文件的时候出现乱码解决
<?php include 'global.php'; $ids = $_GET['ids']; $sql = "select * from crm_cost_end where id ...
- IE浏览器中不支持cookie问题
/** * Cookie plugin * * Copyright (c) 2006 Klaus Hartl (stilbuero.de) * Dual licensed under the MIT ...