Coder Social home page Coder Social logo

python-exercises's Introduction

python-exercises

Some exercises for learning python.

  1. Rename file

Q1: Write a program that renames all files in a directory and its subdirectories, replacing spaces with underscores. For example, the file "My Program.py" would be renamed to "My_Program.py". Multiple consecutive spaces should be treated as a single space.

Q2: There are some pictures in the directory, and the pictures's name randomly generated. Write a program that renames all pictures in the directory. The new name is the created time of the picture. For example, "2018-01-19_12-34-56.jpg".

Q3: There are some pictures in the directory, and the pictures's name randomly generated. Write a program That renames all pictures in the directory, and the new names are like "1.jpg", "2.jpg", "3.jpg", and so on. If the total number of pictures is more than 10, the new name is like "01.jpg", "02.jpg", "03.jpg", and so on. If the total number of pictures is more than 100, the new name is like "001.jpg", "002.jpg", "003.jpg", and so on. The order of numbers depends on the created time of the picture.

Q4: Write a program that renames a file. For example, the file "tranning-log.pdf" should be renamed to "第47届世界技能大赛网络系统管理项目训练日志-选手-郑嘉禄-2022.11.30-Linux.pdf". The frist field is fixed, and the other fields are specified by the parameters of the program when it is executed. Please check the validity of the parameters:

  • The second field must be chosen between "选手" and "教练".
  • The third field must be a valid chinese name.
  • The fourth field must be a valid date and not later than today.
  • The fifth field must be chosen from "Linux", "Windows", "Network", "English", "TS", "Other".
  • All fields must be sepcified unless it has a default value.

python-exercises's People

Contributors

hdaojin avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.