我想将一个长字符串(特别是SQL查询)存储到一个变量中,为了更好的可读性,我想在更多的行中写入该变量
如果这很重要的话,我正在Python3.5(Anaconda)上使用Jupyter笔记本
我试过:
# SQL query
query = "
SELECT
Sued
,ApplicationNumber_Primary
--,ApprovedLoanAmount, ApprovedLoanDuration, ApprovedMonthlyPayment,
,RequiredLoanDuration, RequiredMonthlyPaymentAmount, RequiredPaidAmount, RequiredCoefficientK1
,ClientFreeSources, ClientTotalIncome, ClientNetIncome, ClientTotalExpenditures
,ClientAgeToApplicationDate, ClientFamilyStatusID, ClientEmploymentDuration, CreditExposure
,CalendarQuarter, MonthOfYear, WeekOfYear, DayOfMonth, DayOfWeek, RegionID, DistrictID, ZIPcodeID
FROM
dbo.vRisk
GO
"
…它不会像我希望的那样将字符串存储到变量中
我们将不胜感激
尝试使用三重引号:
使用多行字符串或在其中穿插“\n”:
Python.org string documentation
(最后一个的来源:https://stackoverflow.com/a/10660443/7505395)
相关问题 更多 >
编程相关推荐