我想生成以下行
1 & {\QPCSymbols\XeTeXglyph 2} & \textarabic{الحمدلله} & \texttt{!} & \verb$\XeTeXglyph 2$ \\
\hline
假设第一个数字是n
,第二个数字是n+1
,的内容\textarabic
是从获得的,从的f_nusoos
内容。两个文件的行数相同。\texttt
f_keys
我创建了一个 Python3 脚本,它应该可以得到我想要的,但我最终得到了新的行符号 ( \n
)。
这是我到目前为止所拥有的,
#! python3
import linecache
f_nusoos = 'symbol_nass_list.txt'
f_keys = 'symbol_key_list.txt'
contentfile = open('content.tex', 'w+', encoding="utf-8")
theLine = " "
for x in range(3):
contentfile.write('{} & {{\QPCSymbols\XeTeXglyph {}}} & \\textarabic{{{}}} & \\texttt{{{}}} & \\verb$\XeTeXglyph {}$ \\\\'.format(x+1, x+2,linecache.getline(f_nusoos, x+1).rstrip('\n'), linecache.getline(f_keys, x+1), x+2).rstrip('\n'))
contentfile.write('\hline')
执行后的内容content.tex
是,
1 & {\QPCSymbols\XeTeXglyph 2} & \textarabic{بسم الله الرحمن الرحيم} & \texttt{!
} & \verb$\XeTeXglyph 2$ \\\hline2 & {\QPCSymbols\XeTeXglyph 3} & \textarabic{بسم الله الرحمن الرحيم} & \texttt{"
} & \verb$\XeTeXglyph 3$ \\\hline3 & {\QPCSymbols\XeTeXglyph 4} & \textarabic{بسم الله الرحمن الرحيم} & \texttt{#
} & \verb$\XeTeXglyph 4$ \\\hline
然而,我的期望是,
1 & {\QPCSymbols\XeTeXglyph 2} & \textarabic{بسم الله الرحمن الرحيم} & \texttt{!} & \verb$\XeTeXglyph 2$\\
\hline
2 & {\QPCSymbols\XeTeXglyph 3} & \textarabic{بسم الله الرحمن الرحيم} & \texttt{"} & \verb$\XeTeXglyph 3$\\
\hline
3 & {\QPCSymbols\XeTeXglyph 4} & \textarabic{بسم الله الرحمن الرحيم} & \texttt{#} & \verb$\XeTeXglyph 4$\\
\hline
问题似乎是在texttt{CONTENT
. 我不知道这是为什么。
内容f_nusoos.txt
:
بسم الله الرحمن الرحيم
بسم الله الرحمن الرحيم
بسم الله الرحمن الرحيم
内容f_keys.txt
:
!
"
#