pythonimport timeimport stringimport reimport socketimport threadingtime.sleep(10)print "java"
Import the private module m. py file
#! /Bin/env python # coding: gbk # coding: UTF-8 # The above loading supports the Chinese annotation def plus (a, B ): # "XXX" "is a function description or" this is a test + "a = a + B return a + BUse import to load the m. py Module
#! /Bin/env python # coding: gbk # coding: UTF-8 "Use the sys module to import the specified Python file path" import syssys. path. a
This time for you to bring Python how to get greatest common divisor, Python to find greatest common divisor attention to what, the following is the actual case, together to see.
Before summarizing the greatest common divisor solution in Gartner TAOCP, in fact, the algorithm modification in the after-class problem is to solve the greatest common divisor by the method of the Euclidean division.
My initial understanding of this topic was wrong, and naturally I did not make the standard answer. No
CREATE proc [dbo]. [usp_contacts_select_by_page]--Stored Procedure name@pageindex int,--Current page@pagesize int,--Number of bars per page@pagecount int output,--Total pages@recordcount int output--Total number of barsAsBeginSelect C1.*,c2.groupname to #tmp_contacts from contacts as C1 inner JOINContactgroup as C2 on c1.groupid=c2.groupid--storing data from two tables in a staging tableSELECT * FROM(select *,rn=row_number () over (order by contactId ASC) from #tmp_contacts) as Twhere T.rn betwe
, Bprint "--------------------"A[1] = 'NI'B['c'] = 'spam'print "L, D"print L, Dprint "A, B"print A, B L, D[1, 2, 3] {'a': 1, 'b': 2}A, B[1, 2, 3] {'a': 1, 'b': 2}--------------------L, D[1, 2, 3] {'a': 1, 'b': 2}A, B[1, 'NI', 3] {'a': 1, 'c': 'spam', 'b': 2}
3. Enhanced assignment and shared reference:
X = x + y, x appears twice, it must be executed twice, performance is not good, merging must create object x, and then copy the two lists to merge
Copy/copy
X + = y, x only appears once, and will
Full-stack Python development: python Assignment Method, python Assignment MethodChained assignment
A = 1b = 1c = 1 # For variables with the same value, the following method can be used to assign a value for a = B = c = 1 print (id (a), a) print (id (B), B) together) print (id (c), c)
Result:
Cross assignment
# Swap m, n value m = 1n = 2 # general method temp = mm = nn = tempprint (m, n) # Cross assignment m, n = n, mprint (m, n)
Extract variab
"Java"Import a private module m.py file#!/bin/env python#coding:gbk#coding:utf-8# above loading is support Chinese gaze def plus (A, B): # "" "" XXX "" "is a description of the function or use" "" "" " this is a test + "" a = a+b return a+bLoading the m.py module with import#!/bin/env python#coding:gbk#coding:utf-8 "Importing the path of the specified Python file using the Sys module" Import syssys.path.append ("./") "Importing Python files" Import
connection value, the corresponding changes. The latter (deep copy) is the beginning of a self-built space, the original list of values change, it does not follow the change.3. Annotations (Normalization)1. # TODO: Prompt Before you pass git (not considered here)2, in-line comment Balabala # Balabala3. Single line Comment # Balabala4, multi-line Comment ""5, function, class internal commentdef foo (name, age):"""What is this function for?:p Aram Name: User name, must be a string type:p Aram Age
. The inspect module is described in section 3rd of this article.2.1. Modules (module)__DOC__: Document String. If the module does not have a document, this value is none.*__name__: The module name is always defined, even if you use import. As it takes an alias, or assigns another variable name.*__dict__: contains a dictionary of the property names-attributes available in the module; The object that can be accessed by using the module name. Property name.__FILE__: Contains the file path for the
Python formatted outputname = "laowang" age = 18 print(age) print(type(name)) print(name + str(age)) print("老王今年%d岁"%age) print("%s今年%d岁"%(name,name)) Print floating-point numbers (Specify the number of decimal places reserved) * *Print ("His height is%.2f m"% (1.83))Effect for his height is 1.83 mPrint ("Hello")Print ("World")If she doesn't change the line display, you can changePrint ("Hello", end= "")Print ("World")Print default
"Import a private module m.py file#!/bin/env python#coding:gbk#coding:utf-8# above loading is supported in Chinese note def plus (A, B): # "" "" XXX "" "is a description of the function or use" "" "" "" " this is a test + "" a = a+b return a+bLoad m.py module with import#!/bin/env python#coding:gbk#coding:utf-8 "Importing the path of the specified Python file using the Sys module" Import syssys.path.append ("./") "Importing Python files" Import M
output the aid;Command ActionA toggle a bootable flagb Edit BSD DisklabelC Toggle the DOS compatibility flagDDelete a partition note: This is the action of deleting a partition;LList known partition types Note: L is a list of partition types for us to set the corresponding partition type;mPrint this menu Note: M is a list of help information;NAdd a new partition note: Adds a partition;o Create a new empty DOS partition tablePPrint the partition table
(beststump) expon= Multiply ( -1*alpha*mat (classlabels). T,classest)#exponent for D Calc, getting messyD = Multiply (D,exp (expon))#Calc New D for next iterationD = d/d.sum ()#Calc Training error of all classifiers, if this is 0 quit for loop early ( use break)Aggclassest + = alpha*classest#print "Aggclassest:", aggclassest.tAggerrors = Multiply (sign (aggclassest)! = Mat (classlabels). T,ones ((m,1)) Errorrate= Aggerrors.sum ()/mPrint "Total Error:
I. Conversion between files and JSON1. Json.dump ()#/usr/bin/python#coding =utf-8# @Time: 2017/11/13 0:12# @Auther: Liuzhenchuan# @File: JSON-next. PY# #文件相关的#load must have picked up the JSON data from the file, and load must have converted the file into JSON data.#dump's dad. The JSON data is written to the file. # example 1: Writing JSON to a fileImport JSON jsondate = {' A ': 1, ' B ': 2., ' C ': 3, ' d ': 4}with open (' a.txt ', ' w+ ') as FD:json.dump (JSONDATE,FD)#示例: Read the file in JS
Let me ask you a question why the print function prints parameters directly. Even the numbers? For example, print 1 prints 1. We know that the type of 1 is integer (off-topic, 1 is a constant in Python, is also an object of class int, and 1 in Java is a constant), which is supposed to be the string of the parameters that print accepts?Reply:Because the print function first calls the STR () function to convert the parameter to the STR type, and the STR () function calls the __str__ method in the
=0)str = "Woshizhongguoren"regex0 = Re.findall ("Guo", str)Regex1 = Re.findall ("Guo", str,re. I)Print (regex0)Print (REGEX1)STR1 = "Where is"I an hereOh I see ' 'index0 = Re.findall ("^\w+", str1)Index1 = Re.findall ("^\w+", Str1,re. MPrint (index0)Print (INDEX1)#4. Functions#邮箱正则表达式#compile (pattern, flags=0) uses the compile function to precompile a regular pattern before it is used, so it can be reused in later code.#编译其实是很费时的, this will improve e
Create a new partition for our Linux and use the FDISK command.First introduce the FDISK command, which is a partitioning tool. Use the following:
[[emailprotected]beinan]#fdisk/dev/sdacommand (MNBSP;FORNBSP;HELP): here Press M , will output help;commandactionatoggleabootableflagbeditbsd disklabelctogglethedoscompatibilityflagddeleteapartition Note: This is the action to delete a partition;llistknownpartitiontypes Note: L is a list of partition types for us to set the appropriate partition ty
/DEV/SDA equipment as an example, to explain how to use Fdisk to manipulate the addition, delete the partition and other actions;Description of FdiskWhen we go through the FDISK device, into the operation of the corresponding device, we will find the following prompt, taking FDISK/DEV/SDA equipment as an example to the same;[Email protected] beinan]# FDISK/DEV/SDACommand (M for help): pressing m here will output the aid;Command ActionA toggle a bootable flagb Edit BSD DisklabelC Toggle the DOS c
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.