Python メモ

print()の空行

print を呼び出すとその後改行する。そのため空きすぎる時がある。

Python3

print('alpha', end='')
print(str.rstrip('\n'))
print(str.replace('\n',''))
with open(fname,"r") as file:
 for i in file.read().splitlines():
 print(i)

Python2

さくらインターネットにPython3入れたがる理由がわかる。

sys.stdout.write(string)