摘要: #读文件,文件必须存在才能读f=open('操作文件',encoding='utf-8')res =f.read()print(res)f.close()#写文件fw=open('操作文件',mode='a',encoding='utf-8')#使用a会保留原来的数据,w的话会覆盖掉前面的数据fw. 阅读全文
posted @ 2018-11-22 22:28 yulinlin_coding 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 字符串常用函数 # s='.abcd.'# new_s=s.strip('.')#默认去掉字符串两边的空格和换行符,想去掉什么括号中就写什么# print('s',s)# print('new_s',new_s)# t='.hhjDDDhjhj.'# print(t.rstrip('.'))# pr 阅读全文
posted @ 2018-11-22 22:26 yulinlin_coding 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 列表list-数组stus=['苹果','香蕉','橘子','红枣',111.122,]# 下标 0 1 2 3 4#下标,索引,角标#print(stus[4]) #st=[]#空list#st=list()#空list#增加元素stus.append('榴莲')#在list末尾增加一个元素stu 阅读全文
posted @ 2018-11-22 22:18 yulinlin_coding 阅读(133) 评论(0) 推荐(0) 编辑