[英]how to concatenate numeric string
... # etc
MemberID = df2['Guest Number'][row_numberd2]
MemberI = int(MemberID) # tried converting it to int
print (MemberI)
with open("./pdfs/" + MemberI + "%s.pdf" % i, "wb") as outputStream:
output.write(outputStream)
# etc, yes, have tried using MemberI and MemberID above, both wont concatenate
上面輸出以下錯誤; 當它是一個字符串時。 當我轉換為int時,它說它必須是字符串才能連接。 關於如何實現此目標有任何想法嗎?
TypeError: can only concatenate str (not "numpy.int64") to str # error using MemberID
TypeError: can only concatenate str (not "int") to str # Error using MemberI
應該:
MemberID = df2['Guest Number'].astype(str).iloc[row_numberd2]
with open("./pdfs/" + MemberID + "%s.pdf" % i, "wb") as outputStream:
output.write(outputStream)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.