为了账号安全,请及时绑定邮箱和手机立即绑定

python, SyntaxError: EOL while scanning string

python, SyntaxError: EOL while scanning string

开满天机 2023-01-04 15:31:21
我在行 row_output = ... 中有上述错误,我该如何解决?for index, row_content in enumerate(info):row_output = 'C:\Users\khana\Documents\all\' + indexif not os.path.exists(row_output):    os.makedirs(row_output)
查看完整描述

1 回答

?
MMTTMM

TA贡献1869条经验 获得超4个赞

因为“\”在python中是转义字符,但在window中,它也是路径的分割。所以我们可以使用“\\”来区分它们。但是,如果您的操作系统是 mac 或 liunx,则应使用“/”。“/”对于窗口也很有用。所以我认为“/”是最好的选择。


for index, row_content in enumerate(info):

    row_output = 'C:/Users/khana/Documents/all/' + index

    if not os.path.exists(row_output):

        os.makedirs(row_output)


查看完整回答
反对 回复 2023-01-04
  • 1 回答
  • 0 关注
  • 194 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信