Day6-os supplemental operations, send mail, database operations, write Excel, encrypt operations

Source: Internet
Author: User
Tags generator mongodb redis system log redis desktop manager

The 1.map-Loop helps you invoke the function* * Concept of generator * *The output is:the map returns a generator2.filter-the results of the function processing to false to filter out the output of the comparison map and filter:

directory operations in 3.os

Execute system command in 4.OS

One of the commands we might use to view the system log: Os.popen (' Top-n 1 '). Read ()5.datetime ModuleOutput is: The output is a datetime type, for example: the output is:6.Random Module

The output is:7.Log Module

8. Send an emailFirst step: You need to install the e-mail module first pip instal yagmailThe second step: and need to set up in the mail, to QQ mailbox as an example: the third step: first to connect the mailbox, then send the mail operation if you need to be sent or cc more than one person: 9. Database operations The database is divided into two types:
    • Traditional relational database: MySQL, Oracle, Sql_server, Sqllie, DB2
There will be explicit field names: ID name passwd createtime stu etc. data is present on disk with SQL statements to manipulate data tables and tables are related
    • Non-relational database: MongoDB, Redis
NoSQL all data is key:value form of MONGODB data is present on disk Redis data are present in memory connected MySQL database

The data is: The output is: However, if the Fetchall is run first, then run Fetchone or Fetchmany, it will not get, will return none, this is similar to the file operation, the pointer has been moved to the tail. You can also execute an INSERT statement: But it is important to note that after executing an SQL statement like Insert Update, you need to commit and set autocommit=true if you do not want to make a manual commit to the database connection:Connect to a Redis databaseFamiliarize yourself with the Redis visualizer for Redis desktop Manager, select 10 switches to DB10: Connect to Redis in Python: You can also set the data expiration time, and then Redis desktop The manager can see: If Ttl=-1 represents a permanent, valid related operation:There may also be data in a dictionary nested dictionary in Redis, which is called the Bash type, and processing bash type data is another way:But the get data is not a string type but a bash type, so you can write a function to convert it: 10.PYTHON Encryption Operation 11. Write Excel

Day6-os supplemental operations, send mail, database operations, write Excel, encrypt operations

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.