1. Python User interactionThe program will inevitably interact with the user.For example, you would want to get the user's input and print out some returned results to the user. We can implement this requirement by using the input () function and the print function, respectively.1 #! /user/bin/env Ptyhon2 #-*-coding:utf-8-*-3 #Author:visonwong4 5Name = input ("Name:")6age = Int (input ("Age :"))7Job = input
. The slice from I to J consists of all characters marked between I and j edge.
For non-negative indexes, the slice length is the index difference if they are within the boundary. For example, the length of word [1: 3] is 2.
The built-in function Len () returns the string length:
3.1.3 about Unicode
From python3.0, all strings support Unicode.
The advantage of Unicode is that it provides an ordinal number for each text character in each current script
value is constant.Python provides partial support for functional programming. Because Python allows the use of variables, Python is not a purely functional programming language.First, the definitionSimply put, "functional programming" is a "programming paradigm" (programming paradigm), which is how to write a program's methodology.The main idea is to write the operation process as much as possible into a s
O'reilly interviewed Guido van rosum, author of The Python language, and discussed Python 3 and its future development.
In the end, he said: I want to reiterate that the decision to use 3.0 or 2.6 is a personal choice. You are not at risk of being left behind by taking a conservative stance. Both 3.0 and 2.6 are supported by the same core
are saved with 2 bytes, the characters in East Asia are saved in 3 bytes ...stored in this extensible way.OK above understand:1, what ASCII encoding2, what Unicode encoding3, what UTF-8 codeReview the occurrence of garbled characters cause: 1, no character set 2, character set conflictsLook back and see why you need to add the specified code to the second line? In the 2.x version of Python Pyton when expla
Python learning notes (3) and python learning notes
1. in python source code files, if you use non-ASCII characters, you must declare the character encoding in the file header. The declaration is as follows:# Code: UTF-8
2. Unicode encoding: This is the encoding of All characters in the world. Of course, there is no pr
Python Object-Oriented Programming (3) and python Object-Oriented Programming
Encapsulation
1. Why encapsulation?
Encapsulation is to hide the specific implementation details of data attributes and methods and only provide one interface. Encapsulation does not concern about how objects are built.
2. encapsulation includes data encapsulation and function encapsula
Python learning 3 --- sequence, list, tuples, python ---I. Sequence
1.1 sequence Concept
The most basic data structure in pythn is sequence ).
Each element in the sequence is assigned a sequence number-element index. The first index is 0, the second is 1, and so on. Similar to the subscript In arrays and collections in JAVA.
From the back to the front, the last i
called, releasing the allocated memory unit immediately at the end of the call. Therefore, the formal parameter is only valid inside the function. Function call ends when you return to the keynote function, you can no longer use the shape parametricarguments can be constants, variables, expressions, functions, and so on, regardless of the type of argument, and when a function call is made, they must have a definite value in order to pass these values to the parameter. It is therefore necessary
Can strings in Python 3 be changed ?, Python string
Can strings in Python 3 be changed?
The string has changed this method: replace, for example:
A = 'lkjhgfdsa 'a. replace ('l', '000000') '123kjhgfdsa '# return results
From the above example, we can see that str can als
One: Decorator1 function object has a __name__ property, can get the name of the function>>> def now():... print(‘2015-3-25‘)...>>> f = now>>> f()2015-3-25 >>> now.__name__ Span class= "string" > ' now ' >>> f.__name__ ' now ' 2 to enhance now () functions, such as automatically printing the log before and after a function call, but do not want to modify the definition of the now () function, a w
For learning and working needs, while installing the Python 2 and Python 3 interpreters (or Anaconda 2 and Anaconda 3) to facilitate the switch between versions, we need to install the corresponding PIP for two versions
$ sudo apt-get install python-pip
$ sudo apt-get insta
Python learning notes (3) import and reload Python modules and modules
A module is a core concept of the Python program architecture. A large program is usually presented in the form of multiple module files. A module is designed as a master file or a top-level file to start the entire
Python day 6 (3) Python functional programming 1, pythonday
I. Functional Programming Concepts
A function is an encapsulation supported by Python. By splitting a large code segment into a function and calling a function at a layer, we can break down a complex task into a simple task, this decomposition can be called pr
The path to Python (3): The Path to python
This structure is mapped in many languages, and the dictionary is the only built-in ing type in Python.
Here is an example of a dictionary:
phonebook = {'Alice':'2341', 'Beth':'9102', 'Cecil':'3258'}
The name is a key and the number is a value. The numbers are separated by co
Python learning-stage comprehensive exercises 3. python Comprehensive ExercisesPython learning-comprehensive phase Exercise 3
Based on the previous class learning, do the following example exercises: operations that contain folders and files (do not read the code first, and try to write it first. The code is for refere
Python [3]-dictionary dic And set, python dictionary dicsetI. dictionary dict
Dict is stored as a key-value pair. The creation method is to use braces {} and separate the key and value with a colon.
>>> d={'chen':60,'zhang':80}>>> print d{'chen': 60, 'zhang': 80}
Assignment operation
>>> d['chen']=65>>> print d{'chen': 65, 'zhang': 80}
Value: get (). You can set
Python basics 3: re Regular Expressions and python Regular Expressions
A regular expression (or RE) is a small, highly specialized programming language embedded in Python that only matches characters.
1. Character Type:
Common characters and metacharacters;
1) common characters: Most characters and letters will mat
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.