Commit 132af008 by BellCodeEditor

save project

parent a8dc8308
Showing with 18 additions and 1 deletions
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'"""项目介绍:整理数据
#提示1: split()方法
#用法: str.split(str=")
#参数: str是分隔符,默认为所有的空字符,包括:
#空格、换行(n)等。
#作用:通过指定分隔符对字符串进行切片,返回分割后的字符串列表。
#这里是按照空格来分割所有的字符串,因此括号中可以什么都不写,是用默认参数。
#提示2:列表索引与切片
#姓名在第一-列,索引是从0开始数的,因此姓名
#可以用data[0]表示;义卖款就是后面的,即[1:]。
with open(r'C:\Users\1\Desktop\1.txt','r',encoding='utf-8') as file:
a=file.readlines
for i in a:
data=i.split
print(data[0])
print(data[1;])
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment