• SyntaxError: EOL while scanning string literal


    SyntaxError: EOL while scanning string literal

    目录

    SyntaxError: EOL while scanning string literal

    问题:

    解决:

    完整错误:


    问题:

    1. #
    2. import cx_Oracle
    3. from sqlalchemy import create_engine
    4. from sqlalchemy.orm import sessionmaker
    5. from sqlalchemy.ext.declarative import declarative_base
    6. from sqlalchemy import Column, Integer, String, DateTime, Boolean,Float
    7. class OracleDB(object):
    8. Base = declarative_base()
    9. def __init__(self,user='xxxx',password='xxxx',dabatase='xxxx',serverip='1.1.1.1',port='1'):
    10. user = user #'root'
    11. password = password
    12. database = dabatase
    13. serverip = serverip
    14. dns = cx_Oracle.makedsn(serverip, port, service_name=dabatase)
    15. self.engine = create_engine("oracle://"+user+":"+password+"@" + dns, encoding='utf-8', echo=True)
    16. # Session = sessionmaker(bind=self.engine)
    17. # self.session = Session()
    18. def getEngine(self):
    19. return self.engine
    20. engine = OracleDB().getEngine()
    21. sql = "select distinct,productid,time,power,health,restore,sales,flow_history,weight,current,resistance,material,hot,name,value1,value2,value3,value4,height,width,length from x where flow_history in ('BD','DA','AR','NV') and time>sysdate-1 order by id desc
    22. res = pd.read_sql(sql,engine)
    23. res.head()

    解决:

    发生这种情况的原因是末尾的引号没有加、无论是单引号还是双引号没有加。

    完整错误:

      File "", line 1
        sql = "select distinct,productid,time,power,health,restore,sales,flow_history,weight,current,resistance,material,hot,name,value1,value2,value3,value4,height,width,length from x where flow_history in ('BD','DA','AR','NV') and time>sysdate-1 order by id desc
                                                                                                                                                                                                                                                                        ^
    SyntaxError: EOL while scanning string literal

    Pandas 库是一个免费、开源的第三方 Python 库,是 Python 数据分析必不可少的工具之一,它为 Python 数据分析提供了高性能,且易于使用的数据结构,即 Series 和 DataFrame。Pandas 自诞生后被应用于众多的领域,比如金融、统计学、社会科学、建筑工程等。

    Pandas 库基于 Python NumPy 库开发而来,因此,它可以与 Python 的科学计算库配合使用。Pandas 提供了两种数据结构,分别是 Series(一维数组结构)与 DataFrame(二维数组结构),这两种数据结构极大地增强的了 Pandas 的数据分析能力。我们将学习 Python Pandas 的各种方法、特性以及如何在实践中运用它们。

    Pandas 是 Python 语言的一个扩展程序库,用于数据分析。

    Pandas 是一个开放源码、BSD 许可的库,提供高性能、易于使用的数据结构和数据分析工具。

    Pandas 名字衍生自术语 "panel data"(面板数据)和 "Python data analysis"(Python 数据分析)。

    Pandas 一个强大的分析结构化数据的工具集,基础是 Numpy(提供高性能的矩阵运算)。

    Pandas 可以从各种文件格式比如 CSV、JSON、SQL、Microsoft Excel 导入数据。

    Pandas 可以对各种数据进行运算操作,比如归并、再成形、选择,还有数据清洗和数据加工特征。

    Pandas 广泛应用在学术、金融、统计学等各个数据分析领域。

    Pandas 的主要数据结构是 Series (一维数据)与 DataFrame(二维数据),这两种数据结构足以处理金融、统计、社会科学、工程等领域里的大多数典型用例。

    DataFrame 是一个表格型的数据结构,它含有一组有序的列,每列可以是不同的值类型(数值、字符串、布尔型值)。DataFrame 既有行索引也有列索引,它可以被看做由 Series 组成的字典(共同用一个索引)。
     

  • 相关阅读:
    APP中有html5页面的时候,怎么进行元素定位
    网页信息采集-网页数据采集方法
    Python函数与参数
    儿童台灯哪个品牌比较好?精选央视消费主张推荐的护眼灯
    论文翻译:2021_Joint Online Multichannel Acoustic Echo Cancellation, Speech Dereverberation and Source Separation
    ArcMap中矢量数据修改标注Label的方法
    NPDP产品经理证书是什么行业的证书?
    Java中Servlet的生命周期
    请求和响应的概述
    unity资源管理之Addressable
  • 原文地址:https://blog.csdn.net/zhongkeyuanchongqing/article/details/126051357