我有一个乳胶表,用于每周的课程计划,我想从教学大纲中提取数据,并将其存储为列表。(它们将从 csv 中读取)所以教学大纲是 50 个章节的列表,乳胶有 2 个空间四年级每周一节课,六年级每周三节课,我想咬第一节课,坚持第一节课,然后下一节课。. . 现在我的代码只会在星期一、星期三和星期五给我第 1 章,而不是 ch1、ch2、ch3
math6 = ['chapter1', 'chapter2', 'chapter3', 'chapter1-3test']
math4= ['chapter1.1', 'chapter1.2-3', 'chapter2']
\begin{tabular}{|p{0.7in}|p{0.8in}|p{2.2in}|p{.9in}|p{2.6in}|p{1.6in}|}
6${}^{th}$ Math \newline M\newline & _math6_&
6${}^{th}$ Math \newline W \newline & _math6_ &
6${}^{th}$ Math \newline F \newline & _math6_ &
4${}^{th}$ Math \newline M\newline & & _math4_ &
4${}^{th}$ Math \newline W\newline & & _math4_ &
\end{tabular}
这是蟒蛇
import re
template = file('file1.txt', 'r').read()
lost= ["geography", "physics", "hairdressing", "torah"]
n =0
while n<len(lost):
temp=lost[n]
page= re.sub(r'_thing_', temp, template)
print page
n+=1
#page= re.sub(r'_thing_', "martha", template)
#file('result.txt', 'w').write(page)
这给了我
#contents of file1
# Really long Latex
#File that has
# geography, geography, mary, tom, susan, geography
#that I want to replace
#read file1 in as a string, replace, save again
#contents of file1
# Really long Latex
#File that has
# physics, physics, mary, tom, susan, physics
#that I want to replace
#read file1 in as a string, replace, save again
#contents of file1
# Really long Latex
#File that has
# hairdressing, hairdressing, mary, tom, susan, hairdressing
#that I want to replace
#read file1 in as a string, replace, save again
#contents of file1
# Really long Latex
#File that has
# torah, torah, mary, tom, susan, torah
#that I want to replace
#read file1 in as a string, replace, save again