In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "what is the meaning of% and ~ in python". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
What are the meanings of%?
Find the manual
Refer to the appendix index section of the "The Python Libary Reference" python library guide (P1899):
% (percent):
Datetime format, 198, 594, 596
Environment variables expansion (Windows), 377,1798
Interpolation in configuration files, 493
Operator, 31
Printf-style formatting, 51, 65
Itemized according to the usage index in index:
Datetime format: represents the date format
Environment variables expansion environment variable extension
Interpolation in configureation files insert Settings File
Operator: take surplus
Printf-style formatting: output formatting
Environment variable extension:
Expands environment variable placeholders% NAME% in strings like REG_EXPAND_SZ:
ExpandEnvironmentStrings ('% windir%')
'C:\\ Windows'
Insert settings file
Home_dir: / Users
My_dir:% (home_dir) s/lumberjack
My_pictures:% (my_dir) s/Pictures
Example:
Cls_info = ['% s\ n (% d% s)'% (estimator_conf ['name'], estimator_conf [' complexity_computer'] (estimator_conf ['instance']), estimator_conf [' complexity_label']) for estimator_conf in configuration ['estimators']] ~ what does it mean?
Check the manual:
(tilde)
Home directory expansion, 377
Operator, 32
In addition to representing the home directory, the representation operator is the bits of inverted
~ 5cm Murray 6
~-11: 10
It can be understood as taking 0 as the first positive number and the axis symmetry point of the coordinate.
For analysis, see ↓.
Bitwise inverse operator
Bitwise inverse operator ~ rarely used, today see "byte of Python" book examples, here to learn, and then review the basic knowledge of the computer.
The bitwise inverse operator is used to reverse a binary number bitwise, that is, 0 to 1, 1 to 0, and supposedly decimal 5 (0000 0101) should be (1111 1010) decimal 250. however, this is not the case in Python, and the result is as follows:
~-6
five
There are three ways to express the number of symbols in a computer, namely, the original code, the inverse code and the complement code. The three representation methods all have two parts: symbolic bit and numerical bit. The symbolic bit is 0 for "positive" and 1 for "negative", while the numerical bit is different. In computer systems, numerical values are always represented and stored by complements. The reason is that symbol bits and numerical ranges can be processed uniformly by using complements, and addition and subtraction can also be handled uniformly.
The complement of a positive integer is its binary representation, the same as the original code.
The complement of a negative integer whose corresponding positive binary denotes all bits (including symbolic bits, 0 to 1, 1 to 0) and then adds 1.
Python bitwise inverse operation:
~-6
five
Operational analysis:
The complement of-6 is + 6 (0000 0110) and then + 1, which is (1111 1001) + (0000 0001) = (1111 1010), that is,-6 in the computer is stored in (1111 1010), and (1111 0101) is obtained by bit-by-bit inversion. This is the answer 5.
This is the end of the content of "what is the meaning of% and ~ in python". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.