diff --git a/.idea/misc.xml b/.idea/misc.xml index 11aefe8..62978b6 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/.idea/pythonProject1.iml b/.idea/pythonProject1.iml index 78dd7ad..ff009a2 100644 --- a/.idea/pythonProject1.iml +++ b/.idea/pythonProject1.iml @@ -4,7 +4,7 @@ - + \ No newline at end of file diff --git a/Calculate.py b/Calculate.py index 4626036..e975920 100755 --- a/Calculate.py +++ b/Calculate.py @@ -4,11 +4,12 @@ In = input() ''' eval()函数可对括号中的含变量表达式做运算 0 1 2 3 4 5 6 :正向递增序号 -" 1 2 3 4 5 " +a b c d e f g -7 -6 -5 -4 -3 -2 -1 :反向递减序号 使用[]获取字符串中一个或多个字符 -str[0]获取第一个字 str[0:2]获取前两个字 str[0:-1]字符串去掉末位后输出 str[1:]去首位 +str[0]获取第一个字 str[0:2]获取前两个字 str[0:-1]字符串去掉末位后输出 str[1:]去首位 str[m:n[:k]]m位至n位,k为步长 +str[::-1]倒置字符串 ['F', 'f', '℉'] : 列表类型数据 ''' numdata = eval(In[0:-1]) @@ -34,3 +35,17 @@ elif In[-1] in ['C', 'c', '°C']: else: print("Syntax Error") +''' +import math # 引入math库 + +a = float(input()) +b = float(input()) +c = float(input()) +delta = math.pow(b, 2) - 4 * a * c# 计算判别式 +if delta >= 0: + x1 = (-b + math.sqrt(delta)) / (2 * a) + x2 = (-b - math.sqrt(delta)) / (2 * a) #括号很重要!!!!!!!!! + print("X1=", round(x1, 2), " X2=", round(x2, 2)) +else: + print("没有实数解") +''' diff --git a/Turtle.py b/Turtle.py index e16f37a..721b561 100755 --- a/Turtle.py +++ b/Turtle.py @@ -83,7 +83,6 @@ for i in range(0, 5): pendown() circle(100) ''' -''' import turtle @@ -103,4 +102,3 @@ y = [-75, -75, -75, -155, -155] for i in range(5): circle(x[i], y[i], 360, 100, 15, color[i]) turtle.done() -''' diff --git a/iSmartAnsAnalize/scripts.py b/iSmartAnsAnalize/scripts.py new file mode 100644 index 0000000..31acc48 --- /dev/null +++ b/iSmartAnsAnalize/scripts.py @@ -0,0 +1,53 @@ +# 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>', 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() diff --git a/temp.py b/temp.py new file mode 100644 index 0000000..e69de29