1. 创建文件并写入内容
file = open('新文件.txt', 'w', encoding='utf-8')
file.write('。。。')
file.close()
2. 字符串中的相关操作
s.index('元素')
s.remove('元素')
s.count('元素')
s.split('分隔符')
'分隔符'.join(s_list)
3. 集合操作
set(sequence)
set1 - set2
set1.intersection(set2)
set1.union(set2)
4. unicode编码字符
'\u3000'
5. 内建函数zip
x = iter([1,2,6,3,2,1])
list(zip(x,x))
[(1, 2), (6, 3), (2, 1)]
6. 迭代
x = iter([1,2,6,3,2,1])
next(x,'--')
1
--
7. 多条件判断
'字符串' in (。。。)
'字符串' not in (。。。)
8. 列表的简单表达式
[True if s == '/' False for s in strings]
[True for s in strings if s == '/']
9. matplotlib中设置显示中文标签
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimSun']