Home > other >  New Python
New Python

Time:10-26

Inquire the format version ii (day [2-0], day [2:]) what's the meaning of

CodePudding user response:

Day (2-0), day/2:
Slice
Day [start: end: step] # left closed right away
The start is sliced the initial position, if not specified, the default is 0;
End is sliced by the location, if not specified, the default the length of the sequence,
Step step length is sliced, the default is 1,

CodePudding user response:

The
reference 1/f, 7-eleven's reply:
day [2-0], day/2:
Slice
Day [start: end: step] # left closed right away
The start is sliced the initial position, if not specified, the default is 0;
End is sliced by the location, if not specified, the default the length of the sequence,
Step step length is sliced, the default is 1,

How long is the default sequence length, please

CodePudding user response:

The default length is all day [:]

CodePudding user response:

Print (' today is on {} {} '. The format (day (2-0), day (2:))) day [2-0] says take a day of the first two characters, day said 2: took all of the characters, beginning from the second character in the day and will be the results respectively to replace the previous two {}, if day='1012', day [2-0] returns the '10' day [2:] returns' 12 '. As a result of the print statement above the final feedback 'today is October 12'
  • Related