queue content can be used from both ends in different threads at the same time.
import collectionsimport threadingimport timecandle = collections.deque(xrange(5))def burn(direction, nextSource): while True: try: next = nextSource() except IndexError: break else: print '%8s: %s' % (direction, next) time.sleep(0.1) print '%8s done' % direction returnleft = threading.Thread(target=burn, args=('Lef
)In addition, there are a few things to note:
about the SYN timeout when the connection was built . Imagine, if the server side received a SYN Clien sent back to Syn-ack after the client dropped the line, the server did not receive the client back ACK, then, the connection is in an intermediate state, that is unsuccessful, and did not fail. Therefore, the server side if not received within a certain time TCP will be re-syn-ack. Under Linux, the default number of retries is 5 times, the
)In addition, there are a few things to note:
about the SYN timeout when the connection was built . Imagine, if the server side received a SYN Clien sent back to Syn-ack after the client dropped the line, the server did not receive the client back ACK, then, the connection is in an intermediate state, that is unsuccessful, and did not fail. Therefore, the server side if not received within a certain time TCP will be re-syn-ack. Under Linux, the default number of retries is 5 times, the
the Program specifies the order in which cards are dealt from the pack. the input contains pairs of lines, each line containing 26 cards separated by single space characters. the final line of the input file contains#As its first character. cards are represented as a two character code. the first character is the face-value (A = ace, 2-9, t = 10, j = Jack, q = queen, K = King) and the second character is the suit (C = clubs, D = diamonds, H = hearts, S = spades ).
Output
One line of output must
more information, see
log_datefmt_logfile: ‘%Y-%m-%d %H:%M:%S‘
Log_fmt_consoleDefault Value: [% (levelname)-8 s] % (Message) SConsole log information format, more details
log_fmt_console: ‘[%(levelname)-8s] %(message)s‘
Log_fmt_logfileDefault Value: % (asctime) s, % (msecs) 03.0f [% (name)-17 S] [% (levelname)-8 s] % (Message) S% (Asctime) S: 16:49:45% (Msecs) 03.0f: Current Time in milliseconds% (Name): log record the name of the caller% (Levelname)
; Chapter 6 contains procedures for multiple segments; 1, the following program implementation uses memory 0-0 in sequence ~ In unit 0: 15, the data in the program is rewritten to complete the program:Assume Cs: codesgCodesg segmentDW 0123 H, 0456 H, 0789 H, 0 abch, 0 defh, 0 fedh, 0 cdah, 0987 HStart: mov ax, 0MoV ds, axMoV BX, 0MoV CX, 8S: mov ax, [BX]MoV Cs: [BX], axAdd Bx, 2Loop sMoV ax, 4c00hInt 21 hCodesg endsEnd start
; 2. The following program
not before the variable in the brackets.
#!/bin/bashvar1=1var2=2result1=$[var1+var2]result2=$[$result1+1]result3=$((result2+1))result4=$(($result3+1))echo $result1 $result2 $result3 $result4
In the shell environment, you can use let, [], () to perform basic arithmetic operations.
Let
Let's arithmetic operations include that let itself can also assign values.
Method 1: simple arithmetic operation
var1=1var2=2let result=var1+var2
Method 2: auto-Increment
Let var2 ++ is equivalent to let var2 =
segmentation, and $0 indicates the entire record */cat/etc/passwd | awk-F ': ''in in {user_count = 0} {printf ("%-5d %-20 s % s \ n", ++ user_count, $1, $7 )} END {print "Found" user_count "users \ n"} '/* Resolution: Use the-F option to specify the separator as': '. The command options are divided into three parts, the first part is "BEGIN {user_count = 0}". Before Running AWK, this command defines a variable to count the number of users; the second part is "{printf (" %-5d %-20 s % s \ n ", +
.
Input
Input data to the Program specifies the order in which cards are dealt from the pack. The input contains pairs of lines, each line containing 26 cards separated by single space characters. The final lineThe input file contains#As its first character. cards are represented as a two character code. the first character is the face-value (A = ace, 2-9, t = 10, j = Jack, q = queen, K = King) and the second character is the suit (C = clubs, D = diamonds, H = hearts,S = spades ).
Output
One lin
prevent garbled files (please note that the file stored in a piece of code is just a normal file, here refers to the file is not executed before we open the file when the garbled)The core rule is that what code the file is stored in, and what encoding it opens.Python2 default Ascii,python3 default Utf-8 unless the file header specifies the encoding method.for python3 such as; When browsing the Web, the server will convert dynamically generated Unicode content to UTF-8 and then to the browserIf
following values:s SM minH hoursD DayW per week (Interval==0 on behalf of Monday)Midnight every morning# example 1:Import Logginglogging.basicconfig (level=logging. DEBUG, format= '% (asctime) s% (filename) s[line:% (lineno) d]% (levelname) s% (message) s ', datefmt= '%a,%d%b%Y%H :%m:%s ', filename= "Myapp.log", filemode= "a") #输出到文档console = logging. Streamhandler () # defines a streamhandler that prints info-level or
handler:Example one-how to not use the configuration file (Streamhandler):Import logging# set up logging to File-see previous sections for more Detailslogging.basicconfig (level=logging. DEBUG, format= '% (asctime) s% (name) -12s% (levelname) -8s% (message) s ', datefmt= '%m-%d %h:%m ', filename= '/temp/myapp.log ', filemode= ' W ') # define a Handler which writes INF O messages or higher to the sys.stderr# console = logging. Streamhandler () Console
interpreter, will request memory space to hold "Hello", and then let X point to the memory address, At this time the memory address of the new application is also Unicode encoded Egon, if the code is replaced with x= "Egon". Encode (' Utf-8 '), then the new application memory space is UTF-8 encoded string Egon.Ten, the difference between Python2 and Python3There are two types of string in Python2 str and UnicodeIn Python2, STR is the encoded result bytes, so in Python2, the result of Unicode ch
Control Case
Task:Turns a string from uppercase to lowercase, or to a row.Solution:>>> A ='a'. Upper ()>>>a'A'>>> B ='b'. Lower ()>>>b'b'>>>Print "I Love PythOn". Capitalize () I love Python>>>Print "I Love PythOn". Title () I Love PythonAccessing substrings
Task:Gets a portion of a string.Solution:Slicing is a good way, but it can only get one field at a time:Afield = Theline[3:6]If you also need to consider the length of the field, Struct.unpack may be more appropriate. For example
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.