各位大佬帮帮忙,谢谢啦
file = str(open('D:\\string1.txt',encoding='UTF-8'))print(file)
def search(str1):
length = len(file)
count = 0
for each in range(length-1):
if str1 == file:
count += 1
continue
else:
continue
print(count)
search(']')
各位大佬好,我的这个代码怎么打印出来一直是零呢?小甲鱼的第20次零基础课的课后题.txt文件 file = str(open('D:\\string1.txt',encoding='UTF-8'))得到的是文件的句柄,改成
file = list(open('D:\\string1.txt',encoding='UTF-8')) 试试 冬雪雪冬 发表于 2020-10-27 20:30
file = str(open('D:\\string1.txt',encoding='UTF-8'))得到的是文件的句柄,改成
file = list(open('D:\\ ...
如果我想把这个文件里面的内容变成字符串怎么办啊??? DoubleS、Zhao 发表于 2020-10-27 20:42
如果我想把这个文件里面的内容变成字符串怎么办啊???
file = list(open('D:\\string1.txt',encoding='UTF-8'))
string = ''.join(file)
页:
[1]