Python Learning record-2016-11-28

Source: Internet
Author: User

The modules learned:

Import OS

Import Sys

Import Getpass

Os.system ("Df-h")

Cmd_res = Os.system ("Df-h")

Print (Cmd_res) is 0 because the result is 0, if you want to see the result, use the following notation:

Cmd_res = Os.popen ("Df-h"). Read ()

Os.mkdir ("directory") Create a directory

Print (Sys.path)

View the path to the Python import module

General/usr/lib/python2.7/site-packages

Can import module, import module, without suffix py

If Else usage

user = Jack

passwd = 123456

Username = input ("Username:")

Password = input ("Password:")

If user = = Username:

Print ("username is correct.")

if passwd = = password:

Print ("Welcome log in.")

Else

Print ("Password is invailid.")

Optimization:

user = Jack

passwd = 123456

Username = input ("Username:")

Password = input ("Password:")

If user = = Username and passwd = = password:

Print ("Welcome login.")

Else

Print ("Username or password is invailid.")

Guess Age:

Age = 22

guess_num = Int (input ("Guess your Number"))

If Guess_num = Age:

Print ("Configratulations,you got It")

Elif Guess_num > Age:

Print ("Thins smaller")

Else

Print ("Think bigger")

Python Learning record-2016-11-28

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.