鱼C论坛

 找回密码
 立即注册
查看: 2176|回复: 9

求助啊

[复制链接]
发表于 2014-10-1 13:47:21 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 shuoye 于 2014-10-1 13:50 编辑

帮我看看这是怎么了我打算写个制作upub的程序结果测试分章时除了莫名错误代码运行正常结果很奇葩 2014-10-01 13:45:17 的屏幕截图.png
  1. #!/usr/bin/env python3
  2. #coding=utf-8

  3. import sys
  4. if sys.version_info < (3, 0):
  5.         print('ERROR:Python not > 3.0')
  6.         sys.exit()
  7. import os
  8. import re
  9. import zipfile

  10. class Pyepub:

  11.         def __init__(self, filename, author=None, cover=None):
  12.                 self.filename = filename
  13.                 self.author = author
  14.                 self.cover = cover


  15.         def segmeat(self):
  16.                 os.makedirs('tmp/OPS')
  17.                 old_file = open(self.filename, 'r')
  18.                 new_file = open('tmp/OPS/' + 'chapter0'+ '.html', 'w')
  19.                 chapterlist = open('tmp/OPS/' + 'chapterlist', 'w')
  20.                 chapternum = 0
  21.                 regx = re.compile('^.*第.*章.*



  22. )
  23.                 new_file.write('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN">\n<head>\n<meta http-equiv="Content-Tepe" content="text/html: charset=utf-8" />\n<mets name="provider" content="" />\n<meta name="right" content=""/>\n<link rel="stylesheet" type="text/css" href="css/main.css">\n<script src="js/main.js" type="text/javascript"></script>\n<title>%s</title>\n</head>\n<body>\n<div>\n' % self.filename.split('.')[0])
  24.                 for each_line in old_file:
  25.                         search = regx.search(each_line)
  26.                         if search:
  27.                                 chapternum += 1
  28.                                 new_file.writelines('\n\n</div>\n</body>\n</html>')
  29.                                 new_file.close()
  30.                                 new_file = open('tmp/OPS/' + 'chapter' + str(chapternum) + '.html', 'w')
  31.                                 new_file.write('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN">\n<head>\n<meta http-equiv="Content-Tepe" content="text/html: charset=utf-8" />\n<mets name="provider" content="" />\n<meta name="right" content=""/>\n<link rel="stylesheet" type="text/css" href="css/main.css">\n<script src="js/main.js" type="text/javascript"></script>\n<title>%s</title>\n</head>\n<body>\n<div>\n' % each_line)
  32.                                 new_file.write('<h3>%s</h3>\n' % each_line)
  33.                                 new_file.write('<p>%s</p>\n' % each_line)
  34.                                 chapterlist.write(each_line)
  35.                         else:
  36.                                 new_file.write('<p>%s</p>\n' % each_line)
  37.                 new_file.writelines('\n\n</div>\n</body>\n</html>\n')
  38.                 old_file.close()
  39.                 new_file.close()
  40.                 chapterlist.close()

  41.         def other_file(self):
  42.                 os.mkdir('tmp/META-INF')
  43.                 tf = opem('tmp/META-INF/container.rxml')
  44.                 tf.write('<?xml version="1.0" encoding="UTF-8" ?>\n<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">\n\t<rootfiles>\n\t\t<rootfile full-path="OPS/fb.opf" media-type="application/oebps-package+xml"/>\n\t</rootfiles>\n</container>\n')
  45.                 tf.close()
  46.                 tf = opem('tmp/mimetype', 'w')
  47.                 tf.write('application/epub+zip')
  48.                 tf.close()

  49.         def zipepub(self):
  50.                 pass

  51. if __name__ == '__main__':
  52.         Pyepub(sys.argv[1]).segmeat()
复制代码

小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2014-10-1 14:01:19 | 显示全部楼层
修改了一下更奇葩了成这样了
  1. </p><p>    “不需要。”林晖懒得和对方胡扯,直接迈步离开。方宏这么说无非就是想侮辱他一下,在他眼前秀一下优越感,然后恶心他。
复制代码

还有啊这个小说是我随便在一个不知道名的网站随便点的第一个链接得到的没有广告嫌疑啊
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2014-10-1 15:30:13 | 显示全部楼层
3.4.1
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2014-10-2 05:30:57 | 显示全部楼层

这有什么联系吗
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2014-10-2 08:22:14 | 显示全部楼层
这什么浏览器?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2014-10-2 11:26:27 | 显示全部楼层

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

使用道具 举报

发表于 2014-10-2 19:54:02 | 显示全部楼层
segment吧。还有你这到底什么问题。乱码?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-10-3 06:44:21 | 显示全部楼层
Seandor 发表于 2014-10-2 19:54
segment吧。还有你这到底什么问题。乱码?

嗯,还有写入的行错误应该是<p>内容才对</p>
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-10-4 13:44:18 | 显示全部楼层
一群打酱油的,还是我自己解决了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

头像被屏蔽
发表于 2014-11-1 06:40:33 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-16 10:25

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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