Python uploads local files to Baidu network disk
foreword
- Due to my limited level, it is inevitable that there will be mistakes and omissions, please criticize and correct.
- For more exciting content, you can click to enter the Python daily small operation column, YOLO series column, natural language processing column or my personal homepage to view
- Face Masquerade Detection Based on DETR
- YOLOv7 trains its own data set (mask detection)
- YOLOv8 trains its own data set (football detection)
- YOLOv5: TensorRT accelerates YOLOv5 model reasoning
- YOLOv5:IoU、GIoU、DIoU、CIoU、EIoU
- Playing with Jetson Nano (5): TensorRT accelerates YOLOv5 target detection
- YOLOv5: Add SE, CBAM, CoordAtt, ECA attention mechanism
- YOLOv5: Interpretation of yolov5s.yaml configuration file, adding small target detection layer
- Python converts the COCO format instance segmentation dataset to the YOLO format instance segmentation dataset
- YOLOv5: Use version 7.0 to train your own instance segmentation model (instance segmentation of vehicles, pedestrians, road signs, lane lines, etc.)
- Use Kaggle GPU resources to experience the Stable Diffusion open source project for free
related introduction
- Python is a cross-platform computer programming language. It is a high-level scripting language that combines interpretability, compilation, interactivity and object-oriented. Originally designed for writing automation scripts (shell), as the version is continuously updated and new language features are added, it is more and more used for the development of independent and large-scale projects.
- PyTorch is a deep learning framework, which encapsulates many network and deep learning related tools for us to call, instead of writing them one by one. It is divided into CPU and GPU versions, and other frameworks include TensorFlow, Caffe, etc. PyTorch is launched by Facebook Artificial Intelligence Research Institute (FAIR) based on Torch. It is a Python-based sustainable computing package that provides two advanced features: 1. Tensor computing with powerful GPU acceleration (such as NumPy); 2. , Automatic differentiation mechanism when constructing deep neural network.
- Requests is a popular Python third-party library for sending HTTP requests. It provides a simple and elegant way to interact with web services, including sending HTTP requests of types such as GET, POST, PUT, DELETE, and processing response data.
- Here are some key features and usage of the Requests library:
- Ease of use: The API design of the Requests library is very simple, making sending HTTP requests intuitive and easy to understand.
- Multiple request methods: With functions such as requests.get(), requests.post(), requests.put(), requests.delete(), you can easily send different types of HTTP requests.
- Request parameters: You can add query parameters, request headers, cookies, etc. to the request.
- Request body: For POST and PUT requests, you can pass form data via the data parameter, or JSON data using the json parameter.
- Response handling: The Requests library allows you to get response content in different formats (such as text, JSON, binary data), and provides convenient methods to handle response status codes, response headers, etc.
- Exception handling: The Requests library will throw exceptions when request-related exceptions occur, such as connection timeout, request error, etc. You can use try and except to handle these exceptions.
- Time is a module in the Python standard library for handling time-related operations. It provides a number of functions that enable you to get the current time, process time intervals, format time, and more.
- Here are some key features and usage of the Time module:
- Get the current time: You can use the time.time() function to get the number of seconds of the current time since January 1, 1970 (known as a Unix timestamp). This is useful for measuring time intervals, profiling, etc.
- Formatting Time: With the time.strftime() function, you can format a time object as a string for display in a human-readable form. You can define the output format using a series of formatting directives (eg %Y for year, %m for month, etc.).
- Parsing time: Using the time.strptime() function, you can parse a formatted time string into a time object.
- Time delay: With the time.sleep() function, you can suspend the execution of the program for a specified number of seconds to achieve time delay.
- Time measurement: You can use the time.perf_counter() and time.process_time() functions to measure the actual time of program execution and the processor time.
- Bypy is a third-party Python library for performing operations such as uploading, downloading, and deleting files and directories on Baidu Netdisk through the command line interface. It provides a convenient way to manage your Baidu network disk files, especially useful when you need to operate files in batches.
- Here are some of the main features and usage of Bypy libraries:
- Command line interface: bypy provides a command line interface that allows users to enter commands in the terminal to perform various operations on Baidu Netdisk.
- File upload and download: You can use the bypy upload command to upload local files to Baidu Netdisk, and use the bypy downdir command to download files or directories on Baidu Netdisk.
- File list and query: the bypy list command allows you to list the files and directories in Baidu Netdisk, and the bypy info command is used to get detailed information about files or directories.
- Delete and move: You can use the bypy remove command to delete files or directories on Baidu Netdisk, and use the bypy mv command to move files or directories.
- Batch operations: bypy supports batch operations through wildcards and regular expressions, such as upload, download, delete, etc.
- Authorization and authentication: When using bypy for the first time, you need to authorize once so that it can access your Baidu network disk. This authorization process takes place in the browser.
Python uploads local files to Baidu network disk
Download related dependencies
pip install bypy
get authorization
from bypy import ByPy
bp = ByPy()
print(bp.list())
open link
copy authorization code
Paste the authorization code into the terminal and press Enter
Connect to Baidu Netdisk
Note: The file is placed in the directory of Baidu Netdisk by default
“我的网盘->我的应用数据->bypy”
.
upload files
from bypy import ByPy
bp = ByPy()
bp.upload(
r"d:\Pictures\test.png",
"test.png"
)
print(bp.list())
file synchronization
upload folder
from bypy import ByPy
bp = ByPy()
bp.syncup(
r"./",
"test"
)
print(bp.list())
download folder
from bypy import ByPy
bp = ByPy()
bp.syncdown(
"test",
r"./test"
)
print(bp.list())
- Due to my limited level, it is inevitable that there will be mistakes and omissions, please criticize and correct.
- For more exciting content, you can click to enter the Python daily small operation column, YOLO series column, natural language processing column or my personal homepage to view
- Face Masquerade Detection Based on DETR
- YOLOv7 trains its own data set (mask detection)
- YOLOv8 trains its own data set (football detection)
- YOLOv5: TensorRT accelerates YOLOv5 model reasoning
- YOLOv5:IoU、GIoU、DIoU、CIoU、EIoU
- Playing with Jetson Nano (5): TensorRT accelerates YOLOv5 target detection
- YOLOv5: Add SE, CBAM, CoordAtt, ECA attention mechanism
- YOLOv5: Interpretation of yolov5s.yaml configuration file, adding small target detection layer
- Python converts the COCO format instance segmentation dataset to the YOLO format instance segmentation dataset
- YOLOv5: Use version 7.0 to train your own instance segmentation model (instance segmentation of vehicles, pedestrians, road signs, lane lines, etc.)
- Use Kaggle GPU resources to experience the Stable Diffusion open source project for free