Python小程序--电子书翻页

该博客介绍了如何使用Python实现电子书翻页功能,包括自动翻页和手动翻页两种模式。自动翻页每两秒显示三行内容,直至读完整个文件;手动翻页则需要输入N来逐页查看,输入错误会提示重新输入。实现方法涉及文件读取、时间延迟及用户交互等。
摘要由CSDN通过智能技术生成

目录

1.题目:

2.效果:

3.思路:

4.代码:


1.题目:

电子书翻页:

(1)自动翻页:每次默认读三行,读完之后睡两秒,直到把所有内容全部读出来

(2)手动翻页:输入N阅读下一页,输错提示重新输入,直到把所有内容全部读出来


2.效果:

  • 电子书为:file/a.txt

  • 自动翻页:

              每隔两秒出现三行

              直到a.txt里面的所有内容都显示出来

  • 手动翻页:

输入N显示三行,输错则提示重新再输

直到a.txt的所有内容全部显示出来


利用软硬件通信实现点在翻书系统 public class bookmain { private static String readopenfileadress1 = null;// 翻书程序地址 private static String readmscomm = null; // 串口号 private static Integer settime=null;//设定返回首页的时间 static Process p = null; public static void main(String[] args) throws Exception { // 1.加载文件配置内容 // 此处文件的地址我可以写死,即固定取文件地址 // // long begain = System.currentTimeMillis();//开始系统时间 // try { // Thread.sleep(100); // } catch (Exception e) { // e.printStackTrace(); // } // long CheckTime = System.currentTimeMillis(); //判断时间 // // while(true){ // System.out.println(CheckTime-begain); // try { // Thread.sleep(1000); // } catch (Exception e) { // e.printStackTrace(); // } // CheckTime = System.currentTimeMillis(); // if((CheckTime-begain)>=(5*1000)){//判断时候到30秒 // System.out.println("5秒后结束"); // break; // } // } readtxt("F:\\workspace\\E-BOOK-TURNTO\\bookfileadress.txt"); Enumeration portList = CommPortIdentifier.getPortIdentifiers(); // 得到当前连接上的端口 MscommExchange comm = new MscommExchange(portList, readmscomm); openExe(getReadopenfileadress1()); } // 调用其他的可执行文件,例如:自己制作的exe,或是 下载 安装的软件. public static void openExe(String exe) { Runtime rn = Runtime.getRuntime(); try { p = rn.exec(exe); } catch (Exception e) { JOptionPane.showMessageDialog(null, "打开.exe文件失败", "系统提示", JOptionPane.ERROR_MESSAGE); } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值