【问题标题】:Syntax Error on when adding variable in argument在参数中添加变量时出现语法错误
【发布时间】:2019-04-18 20:36:03
【问题描述】:

我正在尝试将 json 文件的内容添加到文件夹 creds.json 中。但是,我收到一个 s语法错误:扫描字符串文字时 EOL。请指教!

dbutils.fs.put("/user1/creds.json", "{"type": "service_account"}")

【问题讨论】:

    标签: python pyspark databricks


    【解决方案1】:
    dbutils.fs.put("/user1/creds.json", '{"type": "service_account"}')
    

    【讨论】:

    • 你确定?这肯定会修复一个错误。如果您仍然看到错误,则说明您还有其他问题。
    【解决方案2】:

    你不能使用引号in字符串来表示字符串的开始和结束,原因很明显。

    您可以将外引号切换为单引号,转义内引号,或者只使用三引号。

    dbutils.fs.put("/user1/creds.json", """{"type": "service_account"}""")
    

    【讨论】:

      猜你喜欢
      • 2014-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-11
      • 2021-04-17
      • 2020-08-01
      相关资源
      最近更新 更多