python3.6 Basic Data-list-Ganso-string-dictionary 01

Source: Internet
Author: User

#!/usr/bin/env python

#-*-Coding:utf-8-*-

# Single-line comments start with #
# first Comment
Print ("Hello, python!") # a second comment

‘‘‘
Third note
Iv. notes
‘‘‘

"""
Comment Five
Comment Six
"""
Print ("Hello, python!")

# Indent to be consistent or it will be an error
If True:
Print ("True")
Else
Print ("False")

If True:
Print ("Answer")
Print ("True")
Else
Print ("Answer")
Print ("False")

# Multi-line statement
# Python is usually a line to write a statement, but if the statement is long, we can use a backslash (\) to implement a multiline statement, for example:

# total = Item_one + \
# Item_two + \
# Item_three
# in [], {}, or () the multiline statement does not need to use a backslash (\), for example:

Total = [' Item_one ', ' item_two ', ' Item_three ',
' Item_four ', ' item_five ']

# number Type
# There are four types of numbers in Python: integers, long integers, floating-point numbers, and complex numbers.
# int (integer), such as 1, has only one integer-type int, represented as a long integer, and no long in Python2.
# bool (Boolean), as true.
# float (floating point), such as 1.23, 3E-2
# complex (plural), such as 1 + 2j, 1.1 + 2.2j

# string
Word = ' string '
Sentence = "This is a sentence." "
Paragraph = "" "This is a paragraph,
Can consist of multiple lines "" "

Str= ' Runoob '

Print (str) # output string
Print (str[0:-1]) # outputs all characters from the first to the penultimate
Print (str[0]) # The first character of the output string
Print (Str[2:5]) # Output characters from the third start to the fifth
Print (str[2:]) # outputs all characters from the beginning of the third
Print (str * 2) # output String two times
Print (str + ' hello ') # connection string

Print ('------------------------------')

Print (' Hello\nrunoob ') # Escape special characters with backslash (\) +n
Print (R ' Hello\nrunoob ') # adds an R to the front of the string, representing the original string, without escaping

# Wait for user input
Input ("\ n \ nthe exit after pressing the ENTER key.") ")

# Show multiple statements on the same line
Import SYS; x = ' Runoob '; Sys.stdout.write (x + ' \ n ')

# Import and From...import
# import the appropriate modules in Python with import or from...import.
# import the entire module (somemodule) in the format: import somemodule
# import a function from a module in the format: from Somemodule import somefunction
# import multiple functions from a module in the format: from Somemodule import Firstfunc, Secondfunc, Thirdfunc
# import all functions in a module in the format: from somemodule import *
# import SYS Module
Import Sys
Print (' ================python import mode========================== ')
Print (' command-line arguments: ')
For I in SYS.ARGV:
Print (i)
Print (' \ n python path is ', Sys.path)

python3.6 Basic Data-list-Ganso-string-dictionary 01

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.