以下は、PyPDF2ライブラリを使用して2つのPDFファイルを結合するサンプルコードです：

```
import PyPDF2

# Open the first PDF file
pdf1 = open('file1.pdf', 'rb')
pdf1_reader = PyPDF2.PdfFileReader(pdf1)

# Open the second PDF file
pdf2 = open('file2.pdf', 'rb')
pdf2_reader = PyPDF2.PdfFileReader(pdf2)

# Create a new PDF file
pdf_writer = PyPDF2.PdfFileWriter()

# Add the pages from each PDF file to the new file
for page_num in range(pdf1_reader.numPages):
    pdf_writer.addPage(pdf1_reader.getPage(page_num))

for page_num in range(pdf2_reader.numPages):
    pdf_writer.addPage(pdf2_reader.getPage(page_num))

# Save the newly created PDF file
pdf_output = open('joined_file.pdf', 'wb')
pdf_writer.write(pdf_output)

# Close the PDF files
pdf1.close()
pdf2.close()
pdf_output.close()
```

注意: PyPDF2ライブラリはサードパーティライブラリであり、Pythonの標準ライブラリには含まれていません。上記のコードを使用する前に、pip install PyPDF2を使用してインストールする必要があります。
Here is an example code to join two PDF files using the PyPDF2 library:

import PyPDF2

# Open the first PDF file
pdf1 = open('file1.pdf', 'rb')
pdf1_reader = PyPDF2.PdfFileReader(pdf1)

# Open the second PDF file
pdf2 = open('file2.pdf', 'rb')
pdf2_reader = PyPDF2.PdfFileReader(pdf2)

# Create a new PDF file
pdf_writer = PyPDF2.PdfFileWriter()

# Add the pages from each PDF file to the new file
for page_num in range(pdf1_reader.numPages):
    pdf_writer.addPage(pdf1_reader.getPage(page_num))

for page_num in range(pdf2_reader.numPages):
    pdf_writer.addPage(pdf2_reader.getPage(page_num))

# Save the newly created PDF file
pdf_output = open('joined_file.pdf', 'wb')
pdf_writer.write(pdf_output)

# Close the PDF files
pdf1.close()
pdf2.close()
pdf_output.close()

Note: The PyPDF2 library is a third-party library and is not included in the standard library of Python. You will need to install it using pip install PyPDF2 before using the code above.