请帮我看看这个问题。我试图提交任务的工具叫做viope.com网站,这是一个自学环境,它有时会在检查代码时出错。我的代码在第一轮似乎可以正常工作,但我不明白为什么在第二轮选择1时它没有打印,它似乎捕获了文件名的更改。任务另外一个持续的项目,笔记本电脑,也依赖于用户的操作,因为如果用户决定不写任何东西就去读文件,它就会崩溃。在本练习中,我们修复了这个问题,并添加了在程序运行时更改所用笔记本文件的可能性。在

首先,通过检查是否有文件来启动程序“笔记本.txt“如果没有的话就创造一个。如果必须这样做,还应通知用户警告“未找到默认笔记本,已创建一个”。在

当此功能正常工作时,向笔记本添加第四个选项,“(4)更改笔记本”。如果用户选择此选项,系统将提示用户输入新文件“Give the new file name:”。如果存在现有文件,则打开该文件并将其加载到笔记本程序中,而关闭旧的笔记本文件。如果新的笔记本文件不存在,系统会通知用户“没有检测到具有该名称的笔记本,已创建一个。”并生成一个新文件。同时在主菜单“Now using file[filename]”中添加已用笔记本文件的注释。正确的输出应该如下所示:>>>

No default notebook was found, created one.

Now using file notebook.txt

(1) Read the notebook

(2) Add note

(3) Empty the notebook

(4) Change the notebook

(5) Quit

Please select one: 2

Write a new note: Buy milk.

Now using file notebook.txt

(1) Read the notebook

(2) Add note

(3) Empty the notebook

(4) Change the notebook

(5) Quit

Please select one: 4

Give the name of the new file: otherbook.txt

No notebook with that name detected, created one.

Now using file otherbook.txt

(1) Read the notebook

(2) Add note

(3) Empty the notebook

(4) Change the notebook

(5) Quit

Please select one: 2

Write a new note: Buy pineapples.

Now using file otherbook.txt

(1) Read the notebook

(2) Add note

(3) Empty the notebook

(4) Change the notebook

(5) Quit

Please select one: 4

Give the name of the new file: notebook.txt

Now using file notebook.txt

(1) Read the notebook

(2) Add note

(3) Empty the notebook

(4) Change the notebook

(5) Quit

Please select one: 1

Buy milk.:::12:05:23 04/25/11

Now using file notebook.txt

(1) Read the notebook

(2) Add note

(3) Empty the notebook

(4) Change the notebook

(5) Quit

Please select one: 5

Notebook shutting down, thank you.

>>>

我的代码:

^{pr2}$

我的代码输出:# python3.2 ohjelma.py

No default notebook was found, created one.

Now using file notebook.txt

(1) Read the notebook

(2) Add note

(3) Empty the notebook

(4) Change the notebook

(5) Quit

Please select one: 2

Write a new note: Buy milk.

Now using file notebook.txt

(1) Read the notebook

(2) Add note

(3) Empty the notebook

(4) Change the notebook

(5) Quit

Please select one: 4

Give the name of the new file: otherbook.txt

No notebook with that name detected, created one.

Now using file otherbook.txt

(1) Read the notebook

(2) Add note

(3) Empty the notebook

(4) Change the notebook

(5) Quit

Please select one: 2

Write a new note: Buy pineapples.

Now using file otherbook.txt

(1) Read the notebook

(2) Add note

(3) Empty the notebook

(4) Change the notebook

(5) Quit

Please select one: 4

Give the name of the new file: notebook.txt

Now using file notebook.txt

(1) Read the notebook

(2) Add note

(3) Empty the notebook

(4) Change the notebook

(5) Quit

Please select one: 1

Buy milk.:::21:11:24 11/04/11

Now using file notebook.txt

(1) Read the notebook

(2) Add note

(3) Empty the notebook

(4) Change the notebook

(5) Quit

Please select one: 5

Notebook shutting down, thank you.

# python3.2 ohjelma.py

No default notebook was found, created one.

Now using file notebook.txt

(1) Read the notebook

(2) Add note

(3) Empty the notebook

(4) Change the notebook

(5) Quit

Please select one: 2

Write a new note: Buy pineapples.

Now using file notebook.txt

(1) Read the notebook

(2) Add note

(3) Empty the notebook

(4) Change the notebook

(5) Quit

Please select one: 4

Give the name of the new file: otherbook.txt

No notebook with that name detected, created one.

Now using file otherbook.txt

(1) Read the notebook

(2) Add note

(3) Empty the notebook

(4) Change the notebook

(5) Quit

Please select one: 1

Now using file otherbook.txt

(1) Read the notebook

(2) Add note

(3) Empty the notebook

(4) Change the notebook

(5) Quit

Please select one: 4

Give the name of the new file: notebook.txt

Now using file notebook.txt

(1) Read the notebook

(2) Add note

(3) Empty the notebook

(4) Change the notebook

(5) Quit

Please select one: 1

Now using file notebook.txt

(1) Read the notebook

(2) Add note

(3) Empty the notebook

(4) Change the notebook

(5) Quit

Please select one: 5

Notebook shutting down, thank you.

写python的笔记本_python笔记本:更改写入的fi相关推荐

  1. python写日志到文件_python 通过logging写入日志到文件和控制台的实例

    如下所示: import logging # 创建一个logger logger = logging.getLogger('mylogger') logger.setLevel(logging.DEB ...

  2. python 笔记本_Python笔记本

    Python 的主提示符( >>> )和次提示符( ... ).主提示符是解释器告诉你它在等你输入下一个语句,次提示符告诉你解释器正在等待你输入当前语句的其它部分. 下划线(_)在解 ...

  3. 写python脚本管理_Python 文件管理实例详解

    本文实例讲述了Python 文件管理的方法.分享给大家供大家参考,具体如下: 一.Python中的文件管理 文件管理是很多应用程序的基本功能和重要组成部分.Python可以使文件管理极其简单,特别是和 ...

  4. python mysql单元测试_python测试mysql写入性能完整实例

    本文主要研究的是python测试mysql写入性能,分享了一则完整代码,具体介绍如下. 测试环境: (1) 阿里云服务器centos 6.5 (2) 2G内存 (3) 普通硬盘 (4) mysql 5 ...

  5. 阿里云python中文社区_python写中文

    字符串 你的源代码中包含中文的时候,在保存源代码时,就需要务必指定保存为UTF-8编码.当Python解释器读取源代码时,为了让它按UTF-8编码读取,我们通常在文件开头写上这两行: ```pytho ...

  6. python导入mat文件_python读取并写入mat文件的方法

    先给大家介绍下python读取并写入mat文件的方法 用matlab生成一个示例mat文件: clear;clc matrix1 = magic(5); matrix2 = magic(6); sav ...

  7. 阿里云python中文社区_python 写中文

    字符串 你的源代码中包含中文的时候,在保存源代码时,就需要务必指定保存为UTF-8编码.当Python解释器读取源代码时,为了让它按UTF-8编码读取,我们通常在文件开头写上这两行: ```pytho ...

  8. 孤荷凌寒自学python第七十九天开始写Python的第一个爬虫9并使用pydocx模块将结果写入word文档...

    孤荷凌寒自学python第七十九天开始写Python的第一个爬虫9 (完整学习过程屏幕记录视频地址在文末) 今天在上一天的基础上继续完成对我的第一个代码程序的书写. 到今天终于完成了对docx模块针对 ...

  9. python读取excel内容和写入_Python读取和写入Excel文件

    制作Excel表 常用方法说明 Workbook类 Workbook类创建一个XlswWrite的Workbook对象,相当于创建一个excel表 And_worksheet()用来创建工作表,默认为 ...

最新文章

  1. JAVA增删改查XML文件
  2. ASP.NET MVC中实现多个按钮提交的几种方法
  3. esp32摄像显示时间_科普系列 || 第一弹~基于ESP32的WiFi连接
  4. 云计算设计模式(二)——断路器模式
  5. #define c# 报错_c语言中#define的用法
  6. Ubuntu下常用命令总结
  7. 正则表达式【第二卷】
  8. ubuntu 16.04安装网易云音乐
  9. opencv之cv::Mat像素遍历
  10. Fedora安装完必做
  11. 谷歌搜索没有相机图标_教您如何在Google上搜索图片
  12. 3D打印社团的建立和一年的经营
  13. Http请求常见Header
  14. Nhanes临床数据库挖掘教程1----数据库下载
  15. 敏捷概念.Stacey矩阵
  16. 面试题数组L型输出思路
  17. Hrbust 1162 魔女 【dp】
  18. B. Dubious Cyrpto
  19. Mean-shift算法的直观理解
  20. 西工大机考《 催化剂工程》大作业网考

热门文章

  1. Excel导入SQL数据库出现的问题
  2. ASP.Net页面保存持久数据的几种方法比较
  3. 如何更新 Ubuntu Linux
  4. 中老年人旅行有多狂野
  5. init.rc语法与解析
  6. Android10以上之APEX格式介绍
  7. 计算机专业的书普遍都这么贵,你们都是怎么获取资源的?
  8. Ubuntu设置静态IP/网关
  9. java 程序打包成jar_把Java程序打包成jar文件包并执行的方法
  10. 已解决:An error occurred at line: 1 in the generated java file The type java.io.ObjectInputStream canno