[Escape Character]
OS. path. isdir (targetPath) always reports an error. If the string is not valid, it is converted to the file type. After trying many methods, it still does not solve the problem. Finally, we found that, escape characters in the path strings in windows (the examples are copied online, misleading, and low-level errors ).
[Indent]
Python is sensitive to indentation. Working with Notepad ++, examples of copying are space indentation, but Notepad ++ always uses tab indentation, so running always runs wrong indentation error. After unified solution.
[Line Break]
The strings read from the file are line breaks (I cannot try Linux in win) and can be processed by str1.rstrip.
Write () for writing a file does not add line breaks, nor does it specifically add line breaks. The most pitfall is that I add '\ n' to the string, but it turns out to be CRLF, but I only want LF... It seems that there is no solution. Let the next shell solve the problem (tr-d' \ R ').
[Close after file is written]
After the file is written, close () is required to create and save the file. This is common sense.
[Sftp connection]
After checking, the paramiko module is usually used and the GCC dependency is required... If it is used by yourself, the problem is that the script is well written and it is too difficult to transplant it to other machines. Therefore, we call the dos console to run winscp in a very simple way.
The winscp connection script and the folder operations in Linux are not expanded. The string operations in Linux shell are still quite pitfall. The following is a good reference.
Http://www.cnblogs.com/chengmo/archive/2010/10/02/1841355.html