上杉绘梨衣ldy
发表于 2020-9-27 20:55:54
感谢
southcity
发表于 2020-10-13 09:21:53
{:10_247:}
bunchai1707
发表于 2020-10-13 12:41:59
感谢楼主分享
北比臼
发表于 2020-10-19 15:56:00
分享得很详细,收藏了
kxiaoxin
发表于 2020-10-26 11:46:48
很nice
spacex_dragon
发表于 2020-10-27 23:27:11
脑硬盘有限,存不下啊!怎么破?
xjywdltzh
发表于 2020-10-30 11:03:52
看着有点多,有点吃力
shuilingchuang
发表于 2020-11-1 11:29:54
好多方法啊。怎么能熟练掌握
philly_fei
发表于 2020-11-10 02:58:14
#0.
def 输入保存():
file=input("请输入文件名:")
if file.find(".txt")==-1:
file=file+".txt"
print(file)
b=[]
while 1:
a=input("请输入内容 单独输入w输入结束:")
if a=="w":
break
else:
b.append(a+"\n")
f=open(file,"w")
print(b)
f.writelines(b)
f.close()
#输入保存()
def readqian(file,n):
f=open(file)
for i in range(n):
print(f.readline())
f.close()
#readqian("record.txt",6)
def readqian(file,n):
if n.find(":")==-1:
f=open(file)
for i in range(int(n)):
print(f.readline())
f.close()
else:
z=n.split(":")
print(z)
if len(z)==2:
if z=="":#输入:21打印前21行
f=open(file)
for i in range(int(z)):
print(f.readline())
f.close()
elif z=="":#输入21:21行开始到后面内容
f=open(file)
count=0
for i in f:
count=count+1
if count>=int(z):
print(i)
f.close()
else:
count=0
f=open(file)
for i in f:
count=count+1
if count>=int(z) and count<=int(z):
print(i)
if count>int(z):
break
f.close()
else:
print("传入的参数有误")
#readqian("record.txt","4:7")
def tihuan(file,x,y):
f=open(file)
str1=f.read()
f.close()
count=str1.count(x)
str2=input(x+"出现了"+str(count)+"次 是否全部删除 Y/N:")
if str2=="y" or str2=="Y":
b=str1.replace(x,y)
f=open(file,"w")
f.write(b)
f.close()
print(b)
tihuan("record.txt","小甲鱼","小鱿鱼")
jilongshu
发表于 2020-11-23 21:51:44
{:5_91:}{:5_91:}
黑剑么么
发表于 2020-11-24 09:10:19
好多好累
象棋爱好者
发表于 2020-12-1 20:15:50
谢谢
xkpython
发表于 2020-12-2 22:50:59
打卡
英俊聪聪
发表于 2020-12-5 20:05:15
import sys
class Const:
values = []
def __setattr__(self, name, value):
if not name.isupper():
raise TypeError('常量名必须由大写字母组成!')
elif name in self.values:
raise TypeError('常量无法改变!')
else:
self.values.append(name)
super().__setattr__(name, value)
sys.modules = Const()
yf1
发表于 2020-12-13 18:09:18
这个不需要记到笔记上吧,鱼油们
mclb
发表于 2020-12-22 16:13:14
um
mindycooky
发表于 2020-12-23 14:18:45
想看看
lzh_bim
发表于 2020-12-27 22:50:47
{:7_112:}
zzy101
发表于 2020-12-30 15:22:39
1111
敲火火
发表于 2021-1-17 18:41:25
{:10_266:}