Python Scripts Every Freelancer Needs in 2026 (Free Code Included)
FreelanceKit ProWhy Every Freelancer Should Learn Python (Even If You're Not a Developer)
You don't need to be a developer to benefit from Python automation. With 10 lines of code, you can automate tasks that waste hours every week.
1. Auto-Generate PDF Invoices
Stop creating invoices manually in Word. This script generates a professional PDF invoice in 30 seconds:
pip install fpdf2
from fpdf import FPDF
import datetime
def invoice(client, amount, desc, invoice_num):
pdf = FPDF()
pdf.add_page()
pdf.set_font('Helvetica', 'B', 24)
pdf.cell(0, 15, 'INVOICE', align='C', new_x='LMARGIN', new_y='NEXT')
pdf.set_font('Helvetica', '', 12)
pdf.cell(0, 8, f'Invoice #{invoice_num} | Date: {datetime.date.today()}', new_x='LMARGIN', new_y='NEXT')
pdf.cell(0, 8, f'Bill to: {client}', new_x='LMARGIN', new_y='NEXT')
pdf.ln(5)
pdf.set_font('Helvetica', 'B', 14)
pdf.cell(0, 10, f'Total Due: EUR{amount:.2f}', new_x='LMARGIN', new_y='NEXT')
pdf.set_font('Helvetica', '', 11)
pdf.cell(0, 8, f'Services: {desc}', new_x='LMARGIN', new_y='NEXT')
pdf.output(f'invoice_{invoice_num}.pdf')
print(f'Invoice saved as invoice_{invoice_num}.pdf')
invoice('Acme Corp', 2500.00, 'Web Development - April 2026', 42)2. CSV to Excel Report Generator
pip install openpyxl pandas
import pandas as pd
def csv_to_report(csv_file, output_file):
df = pd.read_csv(csv_file)
with pd.ExcelWriter(output_file, engine='openpyxl') as writer:
df.to_excel(writer, sheet_name='Data', index=False)
# Auto-width columns
ws = writer.sheets['Data']
for col in ws.columns:
max_len = max(len(str(cell.value or '')) for cell in col)
ws.column_dimensions[col[0].column_letter].width = min(max_len + 2, 40)
print(f'Report saved: {output_file}')
csv_to_report('clients.csv', 'client_report.xlsx')3. Bulk Email Personalizer
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import csv
def send_bulk_emails(csv_file, gmail_address, gmail_password):
contacts = []
with open(csv_file) as f:
reader = csv.DictReader(f)
contacts = list(reader) # needs: name, email, company columns
server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.login(gmail_address, gmail_password)
for contact in contacts:
msg = MIMEMultipart()
msg['From'] = gmail_address
msg['To'] = contact['email']
msg['Subject'] = f"Quick question for {contact['company']}"
body = f"""Hi {contact['name']},
I noticed {contact['company']} recently...
Best,
Your Name"""
msg.attach(MIMEText(body, 'plain'))
server.send_message(msg)
print(f'Sent to {contact["email"]}')
server.quit()Get 20 More Scripts Free
FreelanceKit Pro — 16 free tools for freelancers, no signup needed
Including: ATS Resume Scanner, Rate Calculator, Contract Generator, Cold Email Writer, and more.