Numbers
- Not a number
float('nan')
. This is often seen in0/0
- In numpy, this is
np.nan
. To check, it’snumpy.isnan()
- In numpy, this is
Print Options
- Multiline Printing
1
2
3
4
print(f'''
line 1
line2
''')
- Print float with 2 decimal digits
1
print(f"{test_acc:.2f}%")
shutil
- remove non-empty directory:
1
shutil.rmtree(DIR)
For-Else Loop
1
2
3
4
5
6
k = 10
for i in range(k):
print(k)
break
else:
print("hello")