Commit 26edfb38 by BellCodeEditor

save project

parent 2f949211
with open(r'C:\Users\86182\Desktop\bell\sales_list.txt','r',encoding='utf-8') as f:
a = f.readline()
print(a)
for i in a:
print(i)
with open(r'/Users/miaoyuan/Desktop/list/poem.txt', 'w', encoding='utf-8') as f:
f.write('锦瑟\n[唐] 李商隐\n锦瑟无端五十弦,'
'\n一弦一柱思华年。'
'\n庄生晓梦迷蝴蝶,'
'\n望帝春心托杜鹃。'
'\n沧海月明珠有泪,'
'\n蓝田日暖玉生烟。'
'\n此情可待成追忆,'
'\n只是当时已惘然。')
poem = ''
with open(r' ', 'r', encoding='utf-8') as f:
for data in f:
if '蓝田日暖玉生烟。' in data:
data = data.replace('蓝田日暖玉生烟。', '_____________。')
if '此情可待成追忆,' in data:
data = data.replace('此情可待成追忆,', '_____________,')
poem += data
with open(r'/Users/miaoyuan/Desktop/list/poem.txt', 'w', encoding='utf-8') as f:
f.write(poem)
with open(r'/Users/miaoyuan/Desktop/list/poem.txt', 'r', encoding='utf-8') as f:
a = f.read()
print(a)
\ No newline at end of file
with open(r'c:\Users\86182\Desktop\sales_list.txt','r',encoding='utf-8') as f:
a=f.readlines()
for i in a:
print(i)
\ No newline at end of file
def draw(a):
import turtle
t = turtle.Pen()
for i in range(a):
t.forward(100)
t.left(360/a)
t.hideturtle()
turtle.done()
draw()
\ No newline at end of file
def abd(x,y):
s = x+y
return s
abd(1,3)
\ No newline at end of file
def wc(a,b):
if a>b:
return a
else:
return b
\ No newline at end of file
def abc(a):
cc = 0
for i in range(a+1):
cc += 1
return cc
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'
# 打开
with open(r'C:\Users\86182\Desktop\book.txt','r', encoding = 'utf-8')as file:
# file.write('小兰:12本\n')
# file.write('小丽:11本\n')
# file.write('李文:9本\n')
# file.write('张伟:16本\n')
# file.close()
# file.write('小强:12本')
# file.write('')
for i in file:
if '小强:12本'in file:
print('数据在文件中')
file = ''
with open(r'C:\Users\86182\Desktop\book.txt','r', encoding='utf-8') as f:
for data in f:
if '小强:10本' in data:
data = data.replace('小强:10本', '小强:11本')
if '小兰:12本' in data:
data = data.replace('小兰:12本', '小兰:14本')
file += data
with open(r'C:\Users\86182\Desktop\book.txt', 'w', encoding='utf-8') as f:
f.write(file)
with open(r'C:\Users\86182\Desktop\book.txt', 'r', encoding='utf-8') as f:
a = f.read()
print(a)
# with open(r'/Users/zengtao/Desktop/bell/text.txt', 'w', encoding='utf-8') as f:
# f.write('小强:10本\n')
# f.write('小兰:10本\n')
file = " "
with open(r'\Users\86182\Desktop\bell\text.txt', 'r', encoding='utf-8') as f:
for data in f:
if '小强:10本' in data:
data = data.replace('小强:10本', '小强:11本')
if '小兰:10本' in data:
data = data.replace('小兰:10本', '小兰:14本')
file += data
with open(r'\Users\86182\Desktop\bell\text.txt', 'w', encoding='utf-8') as f:
f.write(file)
with open(r'\Users\86182\Desktop\bell\text.txt', 'r', encoding='utf-8') as f:
a = f.read()
print(a)
# with open(r'/Users/zengtao/Desktop/bell/text.txt', 'w', encoding='utf-8') as f:
# f.write('小强:10本\n')
# f.write('小兰:10本\n')
file = " "
with open(r'\Users\86182\Desktop\bell\text.txt', 'r', encoding='utf-8') as f:
for data in f:
if '小强:10本' in data:
data = data.replace('小强:10本', '小强:11本')
if '小兰:10本' in data:
data = data.replace('小兰:10本', '小兰:14本')
file += data
with open(r'/Users/86182/Desktop/bell/text.txt', 'w', encoding='utf-8') as f:
f.write(file)
with open(r'/Users/86182/Desktop/bell/text.txt', 'r', encoding='utf-8') as f:
a = f.read()
print(a)
with open(r'C:\Users\86182\Desktop\bell\sales_list.txt','r',encoding='utf-8')as file:
\ 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