First, prepare beforehand
1. Create 1 new project, my name is: Day9-1.
2. Under the Day9-1 directory, New 2 python package:crazyftp and crazyftpclient, respectively, are used to store the client, server-side directories and files.
3. Then create new files and directories on the server side, under the client package directory, as follows:
- Crazyftp
- Bin (User holds executable program directory)
- conf (for storing configuration files)
- Modules (for storing the master file directory)
- Var
- Log (Package directory)
- Users (Package directory)
- Crazyftpclient
- Bin
- ftp_client.py (in the core directory)
- Core
- Var
Second, skills
1. Import all modules in the root file (that is, modules outside the current module directory) method
----Add the server-side "root" directory to the environment variable, which refers to the Crazyftp directory.
1. First import the SYS and OS modules.
2. Then use the Os.path.dirpath method and the Os.path.abspath method to get the "root" of the __file__ (the relative path of the current file). "It's a good idea to take the absolute path first and then to slice it up ..."
3. Add "root" to the environment variable. That is, the sys.path.append (root path).
Import Sysimport Osbase_dir = Os.path.dirname (Os.path.dirname (Os.path.abspath)) #将此路径加入到环境变量里面, That is sys.path.append (directory) sys.path.append (BASE_DIR) from modules import main
Cond.......
Development of Python 1---multiple concurrent FTP