我和这篇文章有同样的问题,但是有多个变量(用宏而不是函数)(Passing a variable from Excel to Python with XLwings)
我试试这个
Sub Hello ()
Dim name,name2 As String
RunPython ("import Test; Test.sayhi('" & Name1 & " , " & Name2 & "')")
End sub
但是我收到了这个错误:
---------------------------
Error
---------------------------
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: sayhi() missing required positional arguments: 'Name2'
如何克服这个错误PLZ?
感谢您的帮助
答案 0 :(得分:1)
您的字符串会解析为单个参数。修复单引号如下:
RunPython ("import Test; Test.sayhi('" & Name1 & "' , '" & Name2 & "')"