●在Python的字符串中

2024-05-15 14:44:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在学习Python,我必须说我喜欢它。但作为一名新学员,我也遇到了一些其他问题:

你们能告诉我这是Python的一个特性还是Python本身的库吗。你知道吗

我正在检查如何连接到sqllite数据库,我提出了这篇文章,下面有一个代码示例:

>>> from pysqlite2 import dbapi2 as sqlite
>>> connection = sqlite.connect('test.db')
>>> memoryConnection = sqlite.connect(':memory:')
>>> cursor = connection.cursor()

当他以字符串形式编写内存时,他还放入了两个:(冒号),我想知道这是否是库所特有的,而不是Python本身。你知道吗


Tags: 代码fromimport数据库示例sqliteconnect特性
3条回答

':memory:'字符串完全依赖于数据库。如documentation for ^{}中所述:

You can use ":memory:" to open a database connection to a database that resides in RAM instead of on disk.

就Python语言而言,':memory:'和其他语言一样只是一个字符串。你知道吗

它是SQLite连接字符串所特有的,与Python无关。你知道吗

发件人:http://nullege.com/codes/search/pysqlite2.dbapi2.connect

You can use ":memory:" to open a database connection to a database that resides in RAM instead of on disk.

冒号不是python专用的

相关问题 更多 >