PyCharm 常用快捷键
复制:Ctrl + d
删除:Ctrl + y
撤回:Ctrl + z
注释:?Ctrl + /
方法跳转:Ctrl + B
最近编辑的文件 Ctrl +e
格式化:Ctrl + Alt + l? (个人修改成Ctrl + Shift + f)
换下一行:Shift + Enter
万能搜素:Shift +Shift
全局关键字搜索:Alt + Shift +r
错误代码修正提示:Alt +Enter
选中代码生成函数:Ctrl + Alt + m
选中代码生成try-except等 Ctrl +?Alt + t
# 变量声明
name = "hello"
age = 19
price = 13.45
is_true = True
# 字符串截取
print(name[0:2])
# 查看数据类型
print(type(name), type(age), type(price), type(is_true))
# 数组
a = array = [1, 2, 3, 4, 5]
# 索引操作数组
print(array[0], array[3])
# 添加元素
array.append(6)
array.extend(["a", "b", 90])
array.insert(0, "test")
# 替换2,下标从1开始,闭头开尾
array[2:5] = [7, 8, 9]
print(array)
# 遍历数组,不换行打印
for i in array:
print(i, end='')
print()
print("----------------------------")
# map
map = {"key1": 123, "key2": "ldj"}
# 遍历map
for key in map.keys():
print(key)
print()
print("----------------------------")
for value in map.values():
print(value)
print()
print("----------------------------")
for kv in map.items():
print(kv)