如何转换字符串python单引号双引号

2024-05-15 22:03:10 发布

您现在位置:Python中文网/ 问答频道 /正文

python新手。我使用了一个名为pdfminer的包,在这个包中,有一个命令pdf2txt.py在下面的代码中使用。我在单引号和双引号上有问题。我想在Windows中像这样使用os.system()

os.system('pdf2txt.py -o "E:\PDF\output.txt" "E:\PDF\A Functional Genetic Approach Identifies the PI3K Pathway as a Major Determinant of Trastuzumab Resistance in Breast Cancer.pdf"')

在Windows中,"E:\PDF\A Functional Genetic Approach Identifies the PI3K Pathway as a Major Determinant of Trastuzumab Resistance in Breast Cancer.pdf"必须使用双引号。在

现在,我使用strSource = "E:\PDF\A Functional Genetic Approach Identifies the PI3K Pathway as a Major Determinant of Trastuzumab Resistance in Breast Cancer.pdf",但是我在os.system()中使用StrSource,它不能得到{}。我认为strSource可能等于'E:\PDF\A Functional Genetic Approach Identifies the PI3K Pathway as a Major Determinant of Trastuzumab Resistance in Breast Cancer.pdf'。如何将'转换为"?在


Tags: oftheinpdfasfunctionalgeneticmajor
2条回答
strTarget = "E:\PDF\output.txt"
strSource = 'E:\PDF\Vascular_smooth_muscle_contraction.pdf'
os.system('pdf2txt.py -o %s %s' % (self.strTarget,self.strSource))

它起作用了!在

如果问题如您所说,那么您可以简单地使用strreplace方法:

strSource = strSource.replace("'", '"')

例如

^{pr2}$

相关问题 更多 >