# Day_06
###
+ : ''/""/'''''''
+ :
+ = ''
+ = ""
+ = """()"""
+ :
+ : []
+ : [start, stop[, step]]
+ :
+ "+" :
+ "*" :
+
+ = ""
+ = str() ( int ,float, bool)
+
+
|
:---: | :---:
**.find()** | -1
.rfind() | -1
**.index()** |
.rindex() |
**.count()** |
**.endswith(suffix[, start[, end]])** | TrueFalsestart end (Python)
**.startswith(prefix[, start[, end]])** | TrueFalsestart end (Python)
+
|
:---: | :---:
.partition() | (str )
.splitlines() | ()
**.split()** | ""maxsplit: maxsplit (maxsplit 1 )
```
>>> str = "124\n441"
>>> str.splitlines()
['124', '441']
>>> str.partition("\n")
('124', '\n', '441')
>>> str.split("4")
['12', '\n', '', '1']
```
+
|
:---: | :---:
**.replace()** |
.translate() | from string import maketrans
+
|
:---: | :---:
**.center(width, fillchar)** |
.ljust(width, fillchar) |
.rjust(width, fillchar) |
.zfill(width) | 0
**.format(value, format_spec)** | {} : % format() {} format()
**.strip(chars)** | (chars : )
.rstrip(chars) | (chars : )
.lstrip(chars) | (chars : )
+
+ format()
```
#
>>> ": {}, : {}:{}".format(19, "", "")
': 19, : :'
#
>>> print(": {2}, : {1}:{0}".format("","", 19))
: 19, : :
#
>>> ": {age}, : {gender}:{name}".format(name="",gender="", age=19)
': 19, : :'
#
>>> info = {"name": "", "age": 18}
>>> ":{name},:{age}".format(**info)
':,:18'
```
+
+ : :[][][]
+ ":" : ()
```
>>> print("{:0>10}".format(""))
00000000
```
+
+ :.2f :
```
>>> print("{:.2f}".format(2))
2.00
```
+ :b :
```
>>> print("{:b}".format(2))
10
>>> print("{:0>10.2f}".format(16))
0000016.00
```
+ :o :
```
>>> print("{:o}".format(16))
20
```
+ :x :
```
>>> print("{:x}".format(16))
10
```
+ -->
|
:---: | :---:
%% |
%s |
%f |
%d/i | ()
+ --> f-string
+ : f"{}"
+ {}
```
>>> f"{2*8}"
'16'
```
+ // /^
+ f"{:.2f}"
```
>>> f"{13:.2f}"
'13.00'
```
+ f"{:d}"
```
>>> f"{13:b}"
'1101'
```
+ f"{:o}"
```
>>> f"{13:o}"
'15'
```
+ f"{:x}"
```
>>> f"{13:x}"
'd'
```
+
|
:---: | :---:
**.upper()** |
**.lower()** |
.swapcase() | str
**.title()** | ****
.capitalize() |
.expandtabs() | tab (\t) (\t 8 )
.casefold() | ****
+
|
:---: | :---:
.isalnum() | str True False
.isalpha() | True False
.isdigit() | True False ( )
.isupper() | ()
.islower() | ()
.istitle() | True False
.isspace() | True False
.endswith(suffix[, start[, end]]) | TrueFalsestart end (Python)
.startswith(prefix[, start[, end]]) | TrueFalsestart end (Python)
**.split()** | ""maxsplit: maxsplit (maxsplit 1 )
+
+ encode() : "utf-8" str -> byte
+ str.encode(encoding="utf-8", errors='strict')
+ encoding: "utf-8" utf-8gb2312cp936gbk
+ errors: "strict" UnicodeEncodeError 'ignore''replace''xmlcharrefreplace' codecs.register_error()
+ decode() : encoding byte -> str
+ str.decode(encoding="utf-8", errors='strict')
+ encoding: "utf-8" utf-8gb2312cp936gbk
+ errors: "strict" UnicodeEncodeError 'ignore''replace''xmlcharrefreplace' codecs.register_error()
+ ()
|
:---: | :---:
\\ | (\)
\' | (')
\" | (")
\n |
\t | (tab) 8
\newline | ()
\other |
+ repr() ( n '\', '\' n+1 '\', repr() n+1 '\' 2n '\', print() n/2 '\')
```
>>> '\\\'
'\\\\'
>>> repr('\\\')
"'\\\\\\\\'"
>>> print('\\\')
\\
```
```python
str = input(" '\\ : ")
str_count = str.count('\\')
while str_count % 2 != 0:
str_count += 1
else:
print(f' \\ {str_count}')
print(f"repr() \\ {str_count*2}")
print(f'print() \\ {str_count//2}')
```
+
+ r R ()