mirror of
https://github.com/WMK965/965-Python-Learning-Repo.git
synced 2025-04-27 14:03:22 +00:00
规范资源位置
This commit is contained in:
parent
196fc7ec50
commit
bfce303263
@ -1,14 +0,0 @@
|
|||||||
import os
|
|
||||||
import glob
|
|
||||||
while True:
|
|
||||||
data = input()
|
|
||||||
print("\n")
|
|
||||||
data = data.rsplit('/', 1)
|
|
||||||
maxpic = int(str(data[1]).split('.')[0])
|
|
||||||
suffix = '.png'
|
|
||||||
for i in range(1, maxpic + 1):
|
|
||||||
print(data[0] + f"/{i}" + suffix)
|
|
||||||
print("\n")
|
|
||||||
path = 'C:/Users/965/Downloads'
|
|
||||||
for infile in glob.glob(os.path.join(path, '*.png')):
|
|
||||||
os.remove(infile)
|
|
@ -1,53 +0,0 @@
|
|||||||
# encoding utf-8
|
|
||||||
import linecache
|
|
||||||
import re
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
def opentxt(num, path, name, line):
|
|
||||||
filename = '.\\{0}\\{1}{2}.txt'.format(path, num, name)
|
|
||||||
cont = linecache.getline(filename, line)
|
|
||||||
return cont
|
|
||||||
|
|
||||||
|
|
||||||
def savetxt(num, path, inv, name, character):
|
|
||||||
filename = '.\\{0}\\{1}{2}.txt'.format(path, num, name)
|
|
||||||
with open(filename, 'w', encoding='UTF-8') as txt:
|
|
||||||
txt.write(inv.replace(character, '\n'))
|
|
||||||
|
|
||||||
|
|
||||||
def txtsearch(num, path, character):
|
|
||||||
filename = '.\\{0}\\{1}_Response.txt'.format(path, num)
|
|
||||||
txt = open(filename, 'r', encoding='UTF-8')
|
|
||||||
lines = txt.readlines()
|
|
||||||
for lines in lines: # 对TXT 进行逐行读取
|
|
||||||
if character in lines:
|
|
||||||
return lines
|
|
||||||
txt.close()
|
|
||||||
|
|
||||||
|
|
||||||
count = 2
|
|
||||||
while count < 26:
|
|
||||||
content = txtsearch(count, 'response', 'answer')
|
|
||||||
texts = re.findall(r'<answers>.*<\\/answers>', content)
|
|
||||||
texts = str(texts)
|
|
||||||
texts = re.findall(r'CDATA\[.]', texts)
|
|
||||||
texts = str(texts)
|
|
||||||
texts = texts.replace("'CDATA[]]'", '\n')
|
|
||||||
texts = texts.replace("CDATA", '')
|
|
||||||
savetxt(count, 'Ans', texts, 'ans', ',')
|
|
||||||
count += 1
|
|
||||||
|
|
||||||
os.chdir(r"C:/Users/965/Builds/iSmartAnsCatch/Ans")
|
|
||||||
filedir = "C:/Users/965/Builds/iSmartAnsCatch/Ans"
|
|
||||||
f = open('../Ans.txt', 'w')
|
|
||||||
# 遍历文件名
|
|
||||||
for i in range(2, 26):
|
|
||||||
filename1 = str(i) + 'ans.txt'
|
|
||||||
if i > 0:
|
|
||||||
filepath = filedir + '/' + filename1
|
|
||||||
# 遍历单个文件 读取行数
|
|
||||||
for line1 in open(filepath, encoding='UTF-8'):
|
|
||||||
f.writelines(str(i - 1) + line1)
|
|
||||||
f.write('\n')
|
|
||||||
f.close()
|
|
Loading…
Reference in New Issue
Block a user