初学python,用代码记录生活

初学python,用代码记录生活,迫不及待的希望将来自己能写各种代码,能够做到孰能生巧,信手拈来,如下代码如有纰漏,诚请各位前辈大佬多多指导!也请原谅作为一个初学者的无所畏惧和不知天高。
s=[0,5,3,4,9,13,20,25]
n=len(s)
for j in range(0,n-1):
for i in range(0,n-1-j):
if s[i]>s[i+1]:
s[i],s[i+1]=s[i+1],s[i]
print(s)

s = [n for n in input(‘请输入列表’).split(’’)]
for i in range(len(s))
try:
s[i]=int(s[i])
except
print(“输入的数字”+str(i+1)+“项有错误”)
exit()
for j in range(0, len(s)-1):
for i in range(0, len(s) - 1 - j):
if s[i] > s[i + 1]:
s[i], s[i + 1] = s[i + 1], s[i]
print(s)

list = []
with open(‘gym.txt’,‘r’) as file_object:
for line in file_object:
list.append(line.strip())
with open(“gym_done.txt”,“w”) as file_object:
for item in sorted(list):
file_object.writelines(item)
file_object.writelines(’\n’)
file_object.close()
print()

你可能感兴趣的:(初学python,用代码记录生活)