And output formatting replication shades
1. stitching strings and formatting
sudo pip3 install ipython installation
ipython enter
String concatenation str1 + str2
'% S'% 12 specify the location splicing
'J% s% s'% (12, 'Good evening') required in brackets
Which you can also add a list
'' .Join ([ 'adjkd', 'disc']), plus one each location, interweaving
'Good evening, I'm {}'. Format ( 'SHE')
"Good evening, a {2} {0} {1} '. Format (' 0 ',' 1 ',' 2 ') indexing, default 0,1,2
Or "Good evening, I {a} {0} {1} '. Format (' 0 ',' 1 ', a = 1)
% D only recognize numbers
% .2d 2 decimal places, you can also rounding.
% F floating point by default reserves six decimal places.
% .2f reserved two floating point
% 5.2f 5 positions, two decimal places, the space is shown,
-5.2% negative sign indicates the left alignment, the minus sign can be added%
% C, ASCII code, wherein a-97 A-65 '% c'% 97 a is
% O 8-ary
% X 16 hex
% E scientific notation
'{: .2}'. Format (1.22222) outputs '1.22'
'{: .2%}'. Format (0.66666) output '66 .60% '
'{A: 5.2f}'. Format (a = 1.22222), a front writing a, be stated later.
'{: <10}'. Format () Left, a total of 10 positions.
'{:> 10}'. Format () right-aligned, a total of 10 positions
'{: ^ 10}'. Format () 10 centered position
. '{: O}' format (), octal
. '{: X}' format () hex
a = '{}'. format a is an address a () is called
% S,% r difference.% R will not escape, the original display format, Print ()
2. Copy the shades
Shallow copy, copy method li2.copy (li), id different
Assignment, a direct reference variable li3 = li, the same id, li follow the change becomes li3
Import introduced copy copy module
deepcopyli = copy.deepcopy(li),
Inner layer change with shallow copy, copy deep nesting level change accordingly.
3.bytes binary type
b = bytes(123)
b = bytes (b'sd ') add b, not directly with the string
Type is bytes. Type (b)
python3 bytes is peculiar in python2 is no distinction between str and bytes.
bytearray (1) a binary array
4.Linux command, view other users
cat / etc / passwd see the user
cat / etc / group View User Groups