Python learning path: day7 and python day7
I have finished learning the basic part of python, and it has been around two months. I feel that I have not learned much. Maybe I forgot too much after learning it.
Because I have no money to buy books, I have no money if I go to training. So I found a book on the internet,
in x, you specify the encoding in the file as UTF-8, but UTF-8 if you want to turn GBK words can not directly turn, need Unicode to do a forwarding site.#!/usr/bin/env python#-*-coding:utf-8-*-#author ChenjingImportChardettim='Hello'PrintChardet.detect (Tim)#decode to Unicode encoding first, then encode from Unicode to GBKNew_tim = Tim.decode ('UTF-8'). Encode ('GBK')PrintChardet.detect (New_tim)#Results" "{' confidence ': 0.75249999999999995, ' enco
When you write a Python program, the name is running normally in the IDE, but there are a variety of problems on the server, and the following errors often occur:Importerror:no module named ' Hello 'I'm sure everyone is not unfamiliar with this mistake. In the early days of learning, especially when you introduce a third-party module (downloaded from the Web or written by yourself), it may happen. What's that for? In
Python timer usage + get script where absolute path + define log format test codeIf you write a script with a timer in Python, if the script also read the configuration file, then the configuration file path if you write to die, one day to change the directory, you need to change the script configuration file
My study notes---python grey hat
The world makes me black and blue, but the wound is wings.--------------------------------------------ObjectiveThis book is written by Mr. Lead author, senior Black Hat Justinseitz, a well-known security Agency IMMUNITYINC, about how programming language Python is widely used in the field of hacking and reverse engineering.Fortunately, I will be interested in this area
Why learn python?There are a lot of development languages, the fastest is undoubtedly the C language, because C is the closest to the language of the machine, but why there are other languages, because the ability to complete the C language may require more code, while other languages may require less code to complete the C requires a lot of code to complete the task, However, Python runs at the slowest spe
Python script output its own directory, than the "C + +" for the current EXE run path (click the Open link), "Java" to take the current. class file compile location (click to open the link) is simple, introduced the OS and Sys inherent class, Can freely output the directory or its own file name, the code is as follows:Import Os;import sys;print os.getcwd ();p rint sys.argv[0];The results of the operation ar
without distortion?17th DayImplement the page batch execution command, the background real-time return resultsThousands of machines performing tasks concurrently, instantly returning results in real timeImplementing the WEB version Server monitoring feature* Monitor server basic status, server performance and drawImplementation of user, by group, according to the computer room and other management software use rights* Enable different operators to use different levels of authority to manage dif
%, display percent (6 digits after the decimal point by default)
Common formatting:1TPL ="I am {}, age {}, {}". Format ("Seven", 18,'Alex')2 3TPL ="I am {}, age {}, {}". Format (*["Seven", 18,'Alex'])4 5TPL ="I am {0}, age {1}, really {0}". Format ("Seven", 18)6 7TPL ="I am {0}, age {1}, really {0}". Format (*["Seven", 18])8 9TPL ="I am {name}, age {age}, really {name}". Format (name="Seven", age=18)Ten OneTPL ="I am {name}, age {age}, really {name}". For
process pool sequence does not have a available process, it waits until a process is availableThe pool module has two common ways to start a processApply and Apply_assync, literally understand that Apply_assync is asynchronous, is actually apply_assync support to pass a function as a parameter in, when the process function is finished, you can return a value, this value, is automatically passed as a parameter to the function passed in, and executes the function, which we call callback (callback
name
Show results
1
zhangsan
The content is encapsulated in the Zhangsan variable, called directly by the Zhangsan instance of the call can be2. InheritanceInheritance is the way a class can inherit another class, the methods and variables of another class, and so on. Is the same as the inheritance in reality.
12345678910111213141516171819
class Role(object):def __init__(self, name):self.name = namedef get_name(self):return self.nameclass
Python path-process excel files with python,
Luo asked me how to read data from excel, and then I made a record.
The following code comes from: http://www.cnblogs.com/lhj588/archive/2012/01/06/2314181.html
Excel Data graph (Mr. Luo said that the data should be kept confidential to the customer, and I wrote several lines of data as needed ):
#! /Usr/bin/env
, callback = WorkTryret = func (*args)Except Exception as E:Print (e)If callback:TryCallback (ret)Except Exception as ex:Print (ex)# # #上面为一个线程执行一次任务的完整流程, once the thread is created, the task is continuously fetched from the queue##### #在执行完一次任务和获取下一次任务的空当内, Thread is idleIf Self.terminate_flag:BreakElseSelf.free_list.append (Current_thread)Work = Self.queue.get ()Self.free_list.append (Current_thread)# #在开始时或者在循环过程中接收到Stop_Flag时 will execute the following statementSelf.generate_list.remove (Cu
=='__main__': -Sessioncls = Sessionmaker (bind=engine)#create a session with the database sessions class, note that this is a class that is returned to the session, not an instance -Session =sessioncls () in #g1= Group (name= ' G1 ') - #g2 = Group (name= ' G2 ') to #g3 = Group (name= ' G3 ') + #G4 = Group (name= ' G4 ') - #Session.add_all ([g1,g2,g3,g4]) the #H1 = Host (hostname= ' H1 ', ip_addr= ' 192.168.1.56 ', port=1000) * #h2 = Host (hostname= ' H2 ', ip_addr= '
Two days ago a colleague asked a Python question:Why a python file in a directory references a Python file that does not have another sibling directory, but the parent record of the two directories can be referenced at runtime. At that time, the feeling has been the module and the mechanism of the package problem, back to turn over the book, found to refer to the
native thread of the operating system. On Linux for Pthread, on Windows for win thread, the execution of threads is fully dispatched by the operating system. A Python interpreter process has a main thread and the execution thread for multiple user programs. Multi-threaded parallel execution is prohibited even on multicore CPU platforms due to the existence of the Gil.
1.4Python installation deployment on 1.4.1Windows side
Download the i
declares a variable named: Name, and the value of the variable name is: "Alex Li"Rules for variable definitions:
Variable names can only be any combination of letters, numbers, or underscores
The first character of a variable name cannot be a number
The following keywords cannot be declared as variable names[' and ', ' as ', ' assert ', ' Break ', ' class ', ' Continue ', ' Def ', ' del ', ' elif ', ' Else ', ' except ', ' exec ', ' finally ', ' for ', ' F ' Rom ', ' Gl
A + = 1 equivalent to a = a + 1
A + = 1
-=
The self-decrement assignment A-= 1 is equivalent to a = A-1
A-= 1
*=
Squared assignment A *= 1 is equivalent to a = a * 1
A *= 1
/=
A/= 1 equivalent to a = A/1
A/= 1
%=
Pickup mode assignment a%= 1 equivalent to a = a% 1
A%= 1
**=
Self-seeking power assignment a **= 1 is equivalent to a = a * * 1
A**= 1
//=
Path to mathematics-python computing practice (13)-machine vision-Image Enhancement-python practice
The basic expression of exponential transformation is y = bc (x-a)-1.
ParametersB,CControl curve transformation shape, ParametersAThe position of the control curve.Exponential transformation is used to expand the image's high gray level and reduce the low gray le
Mathematical path-python computing practice (7)-machine vision-Image Generation addition, zero mean Gaussian noise,-python mean
The image produces zero-mean Gaussian noise and adds noise to the grayscale image. The noise is calculated by adding a gray value of each vertex to the noise value, the Box-Muller algorithm generates Gaussian noise.
In computer simulat
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.