Python Basics: Basics

Source: Internet
Author: User

1. The first sentence of Python

Print ('helloWorld')

The file suffix name of the-python call can be any

-When importing a module, if it is not a. py file, an error will be

-It is recommended to always write the filename suffix as. py

2. Two modes of execution

1) Python interpreter py file path

2) Enter python into the interpreter for real-time input and get to the execution result (Interactive page)

3. Interpreter Path

# !/usr/bin/env python

4. Encoding

# -*-Coding:utf8-*-  

Eg: in a Linux environment,

Filename:

./2.py

Inside the file:

# !/usr/bin/env python
#-*-Coding:utf8-*- % in Python3 this sentence does not need
Print ('helloWorld')

5. Perform an action

Prompt the user to enter a user name and password, if the user name and password are root, the login succeeds

#n is a variable, a variable can only consist of letters, numbers, underscores, cannot start with a number, cannot be named with a python keyword, and cannot be named with Python's built-in functions or classes#Using "" "" "in Python to annotate a programN1 = input ('Please enter user name:') N2= Input ('Please enter the password: ')ifN1 = ='Root'  andN2 = ='Root':Print('Login successful ')Else:Print('Logon Failure') "" "Print(N1)Print(n2) "" "

Python Basics: Basics

Related Article

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.