1. 注释
1.1 单行注释
# 这是语句
pycharm的快捷键: Ctrl + /
1.2 多行注释
‘’’
这是语句
‘’’
或
“”"
这是语句
“”"
2. 输出函数
def print(self, *args, sep=' ', end='\n', file=None): # known special case of print
"""
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
"""
pass
3. 输入函数
def input(*args, **kwargs): # real signature unknown
"""
Read a string from standard input. The trailing newline is stripped.
The prompt string, if given, is printed to standard output without a
trailing newline before reading input.
If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError.
On *nix systems, readline is used if available.
"""
pass
4. 字符串
4.1 字符串的格式
str = 'abcdefghjkl'
4.2 字符串的操作
# 查看类型
print(type(str))
# 获取下标
print(str.index('c'))
# 逆置
print(str[::-1])
# 切片
print(str[0:3]) # 左闭右开
print(str[-3:])
# 注:str[起始位置:结束位置:步长]
# 步长为正数,代表从开始向结束取值
# 步长为负数,代表从末尾向前取值