Last night written a test development volume of Jinshan WPS, make a note (but not the answer, just my idea), about the file and string processing is writing and perfect the first blog, now the title is as follows:
1. Delete all files in the E:\ABC directory using the scripting language:
Use Os.path.exists () to determine if the E:\ABC directory exists, and if there are any files (including subfolders) that use the Shutil.rmtree cascade Delete directory, the error is not present. Note that the Os.remove function cannot delete a folder that has child files.
2. Write a script replacement folder where all the suffixes named. txt are replaced with "= 0" (including the. txt file in the subfolder) in the row containing "= 1":
Use Os.path.exists () to determine if a folder directory exists, and if so, use the stack to traverse the file tree, read the. txt file, and replace the string with the String.Replace () method to re-write to the. txt file.
3. Write a script that batches 100 txt files placed in the D:\temp directory:
To determine whether a directory exists, open the file using the opening method, write the file using the Write method, before you need to determine whether the file name is duplicated.
4. Please design 1 methods to test the WINAPI interface: FindWindow or SetWindowText,
SendMessage Interface Definition: HWND WINAPI FindWindow (lpctstr lpclassname, LPCTSTR lpwindowname);
SetWindowText Interface Definition: BOOL SetWindowText (HWND hwnd, LPCTSTR lpstring)
Algorithms and data Structures:
1. Write down all primes within 1000;
2. Write a sorting algorithm or a de-weight algorithm.
python--file Delete, determine directory presence, string substitution