我对 Python 中字符串的表示有一个小问题。
我有以下 Python 代码:
#!/usr/bin/env python
import sys
import math
import string
from vmtk import pypes
from vmtk import vmtkscripts
seedPointCoordinates = "399 268 364"
targetPointCoordinates = [" 367 264 361 " , "344 287 336 " , " 336 289 330 " , " 315 287 330 " , " 294 278 325 " , " 269 254 321 " ]
for x in range (0,6,1):
myInitializationArguments = "vmtkimageinitialization -ifile <PATH>"\XA_001.dcm -interactive 0 -method fastmarching -upperthreshold 11000 -lowerthreshold 2000 -sourcepoints "+seedPointsOne+" -targetpoints "+targetPointsOne[x]+" -olevelsetsfile <PATH>\initialLevelSets"+str(x+1)+".vti"
myPype = pypes.PypeRun(myinitializationArguments)
myArgumentsForMarchingCubes = "vmtkmarchingcubes –ifile <PATH>\initialLevelSets"+str(x+1)+".vti -ofile <PATH>\initialLevelSets"+str(x+1)+"mc.vtp"
myPype = pypes.PypeRun(myArgumentsForMarchingCubes)
我将其包含在以下 LaTeX 命令中:
\lstinputlisting[language=Python, label={lst:label32}, showstringspaces=false, extendedchars=true,keepspaces=true, tabsize=4, morekeywords={models, lambda, forms}, commentstyle={\rmfamily\catcode`\$=11}, columns=flexible,texcl,showspaces=false, captionpos=b,caption=Example of using the segmentation script with the help of the PypePad command and a Pypes object.]{./PythonCodePart.py}
我的问题是-
编译后符号不出现。而且构造也存在问题<PATH>
...
有人可以帮帮我吗?
答案1
编辑:for 循环中有一个缩进错误,但我懒得上传新图像。
minted
作为 -package 替代方案的简单示例lstlisting
。以上面的代码为例
\documentclass[10pt,a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{minted}
\begin{document}
\begin{minted}{Python}
#!/usr/bin/env python
import sys
import math
import string
from vmtk import pypes
from vmtk import vmtkscripts
seedPointCoordinates = "399 268 364"
targetPointCoordinates = [" 367 264 361 " , "344 287 336 ",
" 336 289 330 " , " 315 287 330 " , " 294 278 325 " , " 269 254 321 "]
for x in range (0,6,1):
myInitializationArguments = "vmtkimageinitialization -ifile <PATH>"
\XA_001.dcm -interactive 0 -method fastmarching
-upperthreshold 11000 -lowerthreshold 2000 -sourcepoints "
+seedPointsOne+
" -targetpoints "
+targetPointsOne[x]+
" -olevelsetsfile <PATH>\initialLevelSets"+str(x+1)+".vti"
myPype = pypes.PypeRun(myinitializationArguments)
myArgumentsForMarchingCubes = "vmtkmarchingcubes –ifile <PATH>\initialLevelSets"
+str(x+1)+ ".vti -ofile <PATH>\initialLevelSets"
+str(x+1)+ "mc.vtp"
myPype = pypes.PypeRun(myArgumentsForMarchingCubes)
\end{minted}
\end{document}
进行了一些清理,结果