python-Comics Auxiliary Script-rename a picture inside a folder to generate HTML

Source: Internet
Author: User

Some comics are sometimes downloaded from the Internet, usually in image format, JPG or PNG. The effect of these pictures online preview is good, but once downloaded to the local, the browser is more troublesome:

Need to flip the arrow keys up and down

By default, the picture is completely displayed in the screen, causing the picture to be small and unclear.

Based on this consideration, write the following Python script, you can read the comic folder images, renamed to a regular picture name to generate the corresponding HTML file, so that you can browse through the HTML image, and browse the effect is much better.

#!\usr\bin\env python#-*-coding:utf-8-*-import os# Gets the current path, PATH = OS.GETCWD () #获取当前路径下所有文件fileList = Os.listdir (path) i= 1for file in Filelist:ext = os.path.splitext (file) [1] #读取后缀为 jpg files and rename them if Ext.strip () = = '. jpg ': Os.rename (file,str (i) +r '. jpg ') i=i+1# create an HTML file locally f=open (R ' index.html ', ' w+ ') for I in Range (1,i): FileName = str (i) +r '. jpg ' image=r ' < IMG src= "' + fileName + R '"/> ' f.write (image) F.close ()

  

python-Comics Auxiliary Script-rename a picture inside a folder to generate HTML

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.