我的目录结构有点像:
A -| |_ B.py C -| |_ D.py
在运行python时,我在C目录中
我需要使用-c选项从cmd执行B.py
像这样的东西:
cd C:\something\C
C:\something\C> python -c "import ..\A\B"
但是导入B抛出错误"SyntaxError: unexpected character after line continuation charcter"
请在下面找到屏幕截图
实际上,我需要在B.py模块内部执行某些功能,因此需要-c选项。整个命令如下所示:
C:\something\C> python -c "import ..\A\B; B.sm_fun()"
谢谢。