Python语言例题集(008)

#!/usr/bin/python3

#建立链表类和遍历此链表

class Node():

def init (self,data=None):

self.data=data

self.next=None

class LinkedList():

def init (self):

self.head=None

复制代码
def printList(self):
	ptr=self.head
	while ptr:
		print(ptr.data)
		ptr=ptr.next

link=LinkedList()

link.head=Node(5)

n2=Node(15)

n3=Node(25)

link.head.next=n2

n2.next=n3

link.printList()

相关推荐
zjy277771 天前
Layui tab选项卡如何动态根据ID值进行程序化切换
jvm·数据库·python
Slow菜鸟1 天前
Codex CLI 教程(五)| AI 驱动项目从零到一:面向 Java 全栈工程师打造个人 ECC(V2版)
java·开发语言·人工智能
lsx2024061 天前
Julia 基本运算符
开发语言
m0_602857761 天前
Redis如何修复槽位分配重叠的脏状态_使用redis-cli --cluster fix工具扫描并修复不一致的Slot
jvm·数据库·python
superior tigre1 天前
78 子集
算法·leetcode·深度优先·回溯
天威?*1 天前
bitset的数据结构用法
算法·动态规划
2301_766283441 天前
怎样开启phpMyAdmin的操作审计日志_记录每条执行的SQL
jvm·数据库·python
tang777891 天前
代理IP质量检测实战:Python实现IP可用性、延迟、匿名度自动测试脚本
大数据·爬虫·python·网络协议·tcp/ip
2501_921649491 天前
企业定制金融数据 API:从架构设计到 Python 接入实战
大数据·开发语言·python·websocket·金融·量化
直奔標竿1 天前
SpringAI + RAG + MCP + Agent 零基础全栈实战(完结篇)| 27课完整汇总,Java开发者AI转型必看
java·开发语言·人工智能·spring boot·后端·spring