大家好,如果以下是字符串,列表或数组,请告诉我:
items =“a”,“b”,“c”,“d”,“e”,“f”,“g”
我很困惑,因为列表或数组通常会以某种括号开头?但是,我的包含多个对象,但我没有使用括号。
请帮忙。
谢谢!
答案 0 :(得分:2)
它是一串字符串。
您可以找到的一种方法是使用type
:
>>> items = "a","b","c","d","e","f","g"
>>> type(items)
<class 'tuple'>
>>> type(items[0])
<class 'str'>
答案 1 :(得分:0)
当元素被彗星分开时,它默认为元组。
您也可以将它们与各种变量对齐:
CREATE View vw_NonStandardDatabaseNames
AS
SELECT DISTINCT
X.DBRealName AS 'Non-Standard Name',*
FROM
(SELECT
db.name AS [DBRealName],
-- Client
(CASE
WHEN PATINDEX ('%[_]%', db.name) > 1
THEN SUBSTRING(db.name,1,PATINDEX ('%[_]%', db.name)-1)
ELSE ''
END) AS [Client],
-- First Underscore
PATINDEX ('%[_]%', db.name) AS [Pos_1],
(CASE
WHEN PATINDEX ('%[_]%', db.name) > 0
THEN '_'
ELSE ''
END) AS [US_1],
(CASE
WHEN PATINDEX ('%[_]DEV%', db.name) > 0
THEN '_'
ELSE ''
END) AS [US_2],
-- Database Name
(CASE
WHEN PATINDEX ('%[_]%', db.name) <= 1
THEN '' -- No Underscore 1
WHEN PATINDEX ('%[_]DEV%', db.name) <= 3
THEN '' -- No Client
WHEN PATINDEX ('%[_]%', db.name) = PATINDEX ('%[_]DEV%', db.name)
THEN '' -- No first underscore only second one + System Name.
WHEN PATINDEX ('%[_]%', db.name)+1 = PATINDEX ('%[_]DEV%', db.name)
THEN '' -- First underscore but no DB Name then second underscore + System Name.
WHEN PATINDEX ('%[_]%', db.name) > 1
AND PATINDEX ('%[_]DEV%', db.name) > 3
THEN SUBSTRING(db.name, PATINDEX ('%[_]%', db.name)+1,(PATINDEX('%[_]DEV%', db.name)-(PATINDEX ('%[_]%', db.name)+1)))
ELSE ''
END) AS [DBName],
-- Second Underscore
PATINDEX ('%[_]DEV%', db.name) AS [Pos2],
-- System Name
(CASE
WHEN PATINDEX ('%[_]DEV%', db.name) > 0 THEN 'DEV'
ELSE ''
END) AS [System_Name],
-- System Name
(CASE
WHEN PATINDEX ('%[_]DEV-%', db.name) > 0 THEN PATINDEX ('%[_]DEV-%', db.name) + 4
ELSE 0
END) AS [POS_3]
---- Hyphen after 'DEV' System Name
-- (CASE
-- WHEN db.name LIKE '%[_]DEV-%' THEN '-'
-- ELSE ''
--END) AS [Hyphen]
---- Version Major
--'' AS [VersionMajor],
--'' AS [Dot1],
---- Version Minor
--'' AS [VersionMinor],
--'' AS [Dot2],
---- Revision
--'' AS [Revision],
--'' AS [Dot3],
---- Build
--'' AS [Build]
FROM sys.databases db
WHERE db.name NOT IN ('master','model','msdb','tempdb')
--UNION
--as above but with 3 digit Version
--UNION
--as above but with 4 digit version
) X
WHERE
X.DBRealName != Concat(X.Client, X.US_1, X.DBName, X.US_2, X.System_Name) --, X.Hyphen, X.VersionMajor, X.Dot1, X.VersionMinor, X.Dot2, X.Revision, X.Dot3, X.Build