基本上,我在Word文档中保存了一个python脚本,并使用excelvba(从电子表格中插入值)对其进行修改,并将其打印到一个.py文件中,以便在命令行中运行。但是,当我将word文档中的脚本打印到.py文件并打开.py文件时,IDE警告“将自动修复混合的行尾字符”,然后脚本中的所有“”都变成类似于§¨的内容。以下是我的vba代码:Dim wddoc As Variant
Dim wdApp As Variant
Dim fileopen As String
Set wdApp = CreateObject("Word.application")
Set wddoc = wdApp.Documents.Open("C:\Users\BLABLA\Desktop\python test\test.docx")
'modifying word document here, inserting value from spread sheet
fileopen = "C:\Users\BLABLABLA\Desktop\python test\testpy.py"
Open fileopen For Append As #1
Print #1, wddoc.Content
Close #1
With wdApp.activedocument
.Close WdDoNotSaveChanges
End With
下面是保存在word文档中的脚本示例
^{2}$
下面是我打印到.py文件时得到的结果:# -*- coding: utf-8 -*-
for i in range(1,10):
print(¡§test¡¨)
¡§¡¨appears to be wrong
我该怎么解决呢?我是个新手,这可能是个愚蠢的问题,但我会感谢你的任何意见。提前谢谢!在