这是我的代码:
SELECT
C.Shortname AS "Customer"
,J.JobReference
,SUM(OH.TotalSellPrice - OH.NonSalesAmount) AS "TotalSellPrice"
,CIL.Amount AS "Contract Invoice"
,CA.Address1
,CA.City
,CA.TaxAreaID
,T.Name AS "Tax Area"
,CA.PostCode AS "ZIP Code"
,OH.DateTimeCreated
,TotalSalesYTD
,J.JobID
,CA.CustomerAddressID
,C.CustomerID
,SaleType
FROM dbo.CustomerAddress AS CA
LEFT JOIN TaxArea AS T
ON CA.TaxAreaID = T.TaxAreaID
LEFT JOIN Customer AS C
ON CA.CustomerID = C.CustomerID
LEFT JOIN Job AS J
ON CA.CustomerAddressID = J.CustomerAddressID
LEFT JOIN CustomerFinancial AS CF
ON CA.CustomerID = CF.CustomerID
LEFT JOIN OrderHeader AS OH
ON CA.CustomerAddressID = OH.DeliveryAddressID
LEFT JOIN ContractInvoicingLine AS CIL
ON OH.ContractInvoicingLineID = CIL.ContractInvoicingLineID
WHERE TotalSalesYTD <> 0
AND OH.DateTimeCreated > '2019-12-31'
AND OH.OrderStatus = 8
AND OH.SaleType = 3
GROUP BY
C.Shortname
,J.JobReference
,CIL.Amount
,CA.Address1
,CA.City
,CA.TaxAreaID
,T.Name
,CA.PostCode
,OH.DateTimeCreated
,TotalSalesYTD
,J.JobID
,CA.CustomerAddressID
,C.CustomerID
,SaleType
ORDER BY
C.ShortName
,JobReference
我想得到一个ahk_second_number = 4
file = open("D:/Arch (all versions)/Work/SCIPE/Data upload script/count_txt_file/patient_count.txt", "w")
file.write("0\n%" % str(ahk_second_number))
file.close() #This close() is important
,第一行包含0,第二行包含patient_count.txt
变量的内容。
它给了我错误:
ahk_second_number
问题:如何在上面更正我的代码,以使我得到runfile('D:/del/untitled0.py', wdir='D:/del')
Traceback (most recent call last):
File "<ipython-input-15-23b229935f25>", line 1, in <module>
runfile('D:/del/untitled0.py', wdir='D:/del')
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "D:/del/untitled0.py", line 3, in <module>
file.write("0\n%" % str(ahk_second_number))
ValueError: incomplete format
(如上所述)所需的信息?
答案 0 :(得分:4)
请尝试以下代码行,而不是您指定的代码行:
import { PubSub } from 'apollo-server';
import * as MESSAGE_EVENTS from './message';
import * as NOTIFICATION_EVENTS from './notification';
export const EVENTS = {
MESSAGE: MESSAGE_EVENTS,
NOTIFICATION: NOTIFICATION_EVENTS,
};
export default new PubSub();
您缺少要编写的变量的格式。 file.write("0\n%d" % ahk_second_number)
表示它写入整数值,因此无需将整数转换为字符串。
编写变量here时,您可以获得有关格式化的更多详细信息。您也可以在official documentation中阅读有关格式的信息。