鱼C论坛

 找回密码
 立即注册
查看: 2701|回复: 2

'r' 和'w'什么意思

[复制链接]
发表于 2016-3-19 12:03:53 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
file1 = open(r'C:\windons\temp\readme.txt','r')
myfile = open('C:\\new\\text.dat','w')
逗号后的’r‘,’w‘从哪来的,什么意思?
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2016-3-19 12:15:01 | 显示全部楼层
第二个参数表示模式, 看文档
  1. Character Meaning
  2. 'r' open for reading (default)
  3. 'w' open for writing, truncating the file first
  4. 'x' open for exclusive creation, failing if the file already exists
  5. 'a' open for writing, appending to the end of the file if it exists
  6. 'b' binary mode
  7. 't' text mode (default)
  8. '+' open a disk file for updating (reading and writing)
  9. 'U' universal newlines mode (deprecated)
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-3-19 12:17:09 | 显示全部楼层
hldh214 发表于 2016-3-19 12:15
第二个参数表示模式, 看文档

谢谢!
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-2-20 07:17

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表