入门教程¶
快速开始¶
环境准备
确保已安装 Python 3.8+
安装步骤¶
1. 安装 Qiskit¶
2. 第一个量子程序¶
from qiskit import QuantumCircuit, Aer, execute
# 创建量子电路
qc = QuantumCircuit(2, 2)
# 添加量子门
qc.h(0)
qc.cx(0, 1)
# 测量
qc.measure([0, 1], [0, 1])
# 执行
backend = Aer.get_backend('qasm_simulator')
result = execute(qc, backend, shots=1000).result()
counts = result.get_counts()
print("测量结果:", counts)