Program ExercisesProgram: Shopping Cart ProgramDemand:
After you start the program, let the user enter the payroll, and then print the list of items
Allow users to purchase items based on their product number
After the user selects the
Python's object-oriented advancedAdvanced levels are: Members of the Python class, member modifiers, special members of the class.I. Members of the classThe members of a class can be divided into three main categories: fields, methods, and
Found himself did not really understand the topological sort, and again learned the next
The topology is sorted to meet the following two conditions
Each vertex appears and appears only once.
If A is preceded by B in the sequence,
Importurllib.requestImportjsoncontent=input ("Please enter what you need to translate:") URL='Http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule'Data={}data['I']=contentdata[' from']='AUTO'data[' to']='AUTO'data['Smartresult']='Dict'
First Program
Open Pycharm, create a new project, create a new file (suffix. py)
Write the simplest code:print(人生苦短,我用python!)
Execute Python code
Using the Pycharm Run button
Terminal input: Python file name
Defining Variables
What is a variable?
The amount of value that can be changed during a program's operation
identifier (command specification)
can only be made up of numbers, letters, underscores
# Object-orientedclass name, each word capitalized class, attributes and behavior must have! Definition of the class:1The . Class is the blueprint and template for objects, and you can create objects with classes2defining a class requires two things:
Make a summary of what you have learned before. Before looking at the two-point search method, can only be like rather than understand the approximate. Now with so many days of accumulation of knowledge can be written on their own.And on the basis
The Python-pip module in CentOS 7 does not exist because of a derivative release like CentOS, where the source and the new lag, or does not exist. Even using Yum to search Python-pip can not find the package.In order to use installation lag or
multithreaded, multi-processMultithreading:The program we open is a process.Threads are included in the process.There is at least one thread inside the processThreads are independent of each otherMain threadCPU is a few cores, it can only run
HBase Python APIHBase enables multi-language programming through the thrift mechanism, where information is passed through the port, so Python is a good choiceSpit GrooveBo Master on Mac configuration hbase, but Zoomkeeper has been error, results
Python listEach element in the list is assigned a number-its position, or index, the first index is 0, the second index is 1, and so on.Create a list by enclosing separate data items separated by commas in square brackets. As shown below:11 List1 = [
Class Member: Field + Method + PropertyFields: Normal (instance objects, saved once per object) + static (global variables, saved only once, all methods shared)Method: Common method (instance method: Self.fun ()) + class method (@classmathod) +
(1) Else in the For loopIn [1]: Nums = [11,22,33,44]in [ for in nums: ...: print(temp Else: #else表示当循环打印完才会打印else里的内容 ... :print(" ======== " ) ...: 11223344========(2) List of append points of attentionIn [3]: a = [11,22,33]in [4
1.TypeError: ' int ' object is not iterable: Scenario Example:data = 7 for in data: print(i)# Cause: An iteration of the int data is done directly, modified to : for I Range (data): print(i)2.TypeError: ' List ' object is not callableScenario
Problem Description: Stitching 16 images into a 4x4 image without changing the pixel value of each individual picture.The code is as follows:1 ImportOS2 fromPILImportImage3Path ='/share1/home/cong/datasets/resized_polyvore/pair1/pair1'4Imglist
question 1. int and list are not the same>>> a=1>>> b=a>>> a+=1>>> A, B (2, 1)>>> a=[ 1,2,3,4]>>> b=a>>> a+=[5]>>> A, b ([1, 2, 3, 4, 5], [1, 2, 3, 4, 5])In layman's words, A and B are "different" when the type is int, and A and B are "the same"
1. IntroductionPython provides a time and calendar module that can be used to format dates and times.The time interval is a floating-point decimal in seconds.Each timestamp is represented by how long it has been since midnight on January 1, 1970
Python daily Bug set and pythonbug
1. TypeError: 'int' object is not iterable:
Scenario example:
Data = 7for I in data: print (I) # cause: it is caused by iteration of int data directly. The value is changed to: for I range (data): print (I)
2.
HTMLTestRunner is changed to Python 3,
Before modification: HTMLTestRunner: Http://tungwaiyip.info/software/HTMLTestRunner.html
BSTestRunner: Https://github.com/easonhan007/HTMLTestRunner
Modified: HTMLTestRunner:
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