Using python to delete the copyright information on the java file header, pythonjava

Source: Internet
Author: User

Using python to delete the copyright information on the java file header, pythonjava

When using others' codes, it is time-consuming and labor-consuming to delete the file header copyright information one by one without retaining it,

Write a script to clear the header copyright information of all files in the directory.

#-*-Coding: utf8-*-''' Delete the copyright of the java file header and other comments on the package ''' import OS import sys def delHeader (filepath ): if OS. path. exists (filepath): file = open (filepath) lines = file. readlines () beforeTag = True writer = open (filepath, 'w') for line in lines: if 'package' in line: beforeTag = False if beforeTag = False: writer. write (line) if _ name _ = '_ main _': path = 'f: \ space \ xxx \ src 'list = OS. wal K (path, True) for dir in list: files = dir [2] for file in files: if '. java 'in file: filepath = OS. path. join (dir [0], file) print filepath delHeader (filepath) print 'complete !!!!!!!!!!!!!!! '

Python call in java

This is because your jython version is inconsistent with the python version installed on your linux. You can refer to the jython version description.
Jython is python implemented using java code. The system library of your jython version may not contain the logging module.

The problem with using source files in python is urgent.

Python history
The founder of Python is Guido van rosum. During the Christmas Day of 1989, in Amsterdam, Guido was determined to develop a new script interpreter as an inheritance of the ABC language in order to make Christmas boring. Python is selected as the program name because it is a fan of the Monty Python flying circus.

ABC is a teaching language (not heard of) designed by Guido ). In Guido's opinion, ABC is a very elegant and powerful language designed specifically for non-professional programmers. However, the ABC language is not successful. The reason is that Guido believes that it is not open. Guido is determined to avoid this error in Python (indeed, it works well with other languages such as C, C ++ and Java ). At the same time, he also wants to implement things that flash in ABC but have never been implemented.

In this way, Python was born in Guido (Thank you very much ). In fact, the first implementation is on a Mac machine. It can be said that Python was developed from ABC and was mainly influenced by Modula-3 (another pretty beautiful and powerful language designed for small groups. It also integrates the Unix Shell and C habits.

Python features
Python is a scripting language, and its syntax is easy to read. It has many excellent scripting languages: Explanatory, object-oriented, built-in high-level data structure, supporting modules and packages, supporting multiple platforms and scalability. It also supports interactive and graphical operations. Its syntax has many distinctive features. Next I will explain it separately:

Running Mode
Python can be run in command line or interactive mode. It also has a graphical integration environment, which makes Python development quite convenient. Now, many visual programming software written in Python has been used to implement functions like Delphi.
Object-oriented
Python is a real object-oriented language. It even supports exception handling. If you have learned Java, you should be familiar with it. However, other scripting languages, such as PHP, do not seem to have any. This makes the compilation of the program clearer without many error checks.
Modules and packages
This is more like Java. For Java support, you can understand JPython. JPython is a Python written in Java. It fully supports Java. In this environment, you can use Java class libraries freely.
Language extension
You can use C, C ++, or Java to write new language modules for Python, such as functions. It can be directly compiled with Python, or implemented using dynamic library loading. Someone has specially compiled a tool that can implement automatic function Interface encapsulation for Python. This is SWIG (Simplified Wrapper and Interface Generator ), or simple encapsulation and interface Builder (you can use it at www.cs.utah.edu /~ Beazley/SWIG ).
Interesting syntax
Guido believes that Python syntax is very elegant. One of them is that the block statement is not a {} pair commonly used in the C language, or another symbol pair, but uses the near representation! Interesting. In this regard, Guido's explanation is: first, using the near representation reduces visual confusion and shortens the program, in this way, the scope of attention to basic code units is reduced. Secondly, it reduces the degree of freedom of the programmer and is more conducive to unified style, making it easier to read other people's programs. I think it is good. in C language, there are several kinds of braces behind the if statement. Different people like different things and it is better to unify them.

After the definition of each class or function... the remaining full text>

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.