项目简介
freeCodeCamp 是一个捐赠支持的非营利编程学习平台,提供从网页开发到数据科学的完整课程。包含交互式挑战、实战项目和认证考试,社区驱动,已帮助数十万人进入科技行业。
README 预览
[](https://www.freecodecamp.org/)\n\n[](https://www.firsttimersonly.com/)\n[](https://discord.gg/PRyKn3Vbay)\n[](https://insights.linuxfoundation.org/project/freecodecamp/repository/freecodecamp-freecodecamp)\n\n## freeCodeCamp.org's open-source codebase and curriculum\n\n[freeCodeCamp.org](https://www.freecodecamp.org) is a friendly community where you can learn to code for free. It is run by a [donor-supported 501(c)(3) charity](https://www.freecodecamp.org/donate) to help millions of busy adults transition into tech. Our community has already helped more than 100,000 people get their first developer job.\n\nOur full-stack web development and machine learning curriculum is completely free and self-paced. We have thousands of interactive coding challenges to help you expand your skills.\n\n## Table of Contents\n\n- [Certifications](#certifications)\n- [The Learning Platform](#the-learning-platform)\n- [Reporting Bugs and Issues](#reporting-bugs-and-issues)\n- [Reporting Security Issues and Responsible Disclosure](#reporting-security-issues-and-responsible-disclosure)\n- [Contributing](#contributing)\n- [Platform, Build and Deployment Status](#platform-build-and-deployment-status)\n- [License](#license)\n\n### Certifications\n\nfreeCodeCamp.org offers several free developer certifications that make up the [Full-Stack Developer Curriculum](https://www.freecodecamp.org/learn/full-stack-developer-v9/):\n\n- [Responsive Web Design](https://www.freecodecamp.org/learn/responsive-web-design-v9/)\n- [JavaScript](https://www.freecodecamp.org/learn/javascript-v9/)\n- [Front-End Development Libraries](https://www.freecodecamp.org/learn/front-end-development-libraries-v9/)\n- [Python](https://www.freecodecamp.org/learn/python-v9/)\n- [Relational Databases](https://www.freecodecamp.org/learn/relational-databases-v9/)\n- [Back-End Development and APIs](https://www.freecodecamp.org/learn/back-end-development-and-apis-v9/)\n\nEach of these certifications involves completing interac
常见问题 (5)
故障排除为什么 Medical Data Validator 的第 9 步会拒绝 `isinstance(dictionary, dict) == False`?
Step 9 测试当前要求条件使用 not isinstance(dictionary, dict)。尽管将布尔结果与 False 进行比较在逻辑上是等效的,但它不符合所接受的测试模式。请将条件替换为:
if not isinstance(dictionary, dict):
print(f'Invalid format: expected a dictionary at position {index}.')
is_invalid = True
这能检测到相同的非字典值,并通过 Step 9 测试。已有人提出一项课程修复,以接受等效的类型检查表达式。
故障排除如何修复在 Python 中将 input() 转换为整数时出现的 “IndexError: string index out of range” 和 ValueError 错误?
Python 序列是零索引的(从 0 开始)。"hello world" 有 11 个字符,索引从 0 到 10;索引 11 已经超出末尾,所以 greet[11] 会抛出 IndexError: string index out of range。使用 greet[-1] 获取最后一个字符,或使用 len(greet) - 1 获取它的索引。
另外,input() 始终返回字符串。只有当该字符串无法用 int() 转换时才会报错,比如输入字母或空值。可以用 try/except 来处理:
greet = "hello world"
print(greet[10]) # d
print(greet[-1]) # d
try:
number = int(input("Enter a number: "))
except ValueError:
print("Please enter a valid integer!")故障排除当我的函数遵循 LIFO 原则,但参数或集合顺序(collection-order)测试仍然失败时,我该如何修复 freeCodeCamp 的 Implement a Stack 测试?
测试以独立函数的形式调用栈操作。initStack() 返回的栈对象作为第一个参数传入,而 push 还会接收新元素作为第二个参数。将元素存储在 stack.collection 中,数组的最后一个元素被视为栈顶。
示例实现:
function initStack() {
return { collection: [] };
}
function push(stack, element) {
stack.collection.push(element);
}
function pop(stack) {
return stack.collection.pop();
}
function peek(stack) {
return stack.collection[stack.collection.length - 1];
}
function isEmpty(stack) {
return stack.collection.length === 0;
}
function clear(stack) {
stack.collection.length = 0;
}
在执行 push(stack, 'first') 和 push(stack, 'second') 之后,测试期望 stack.collection 等于 ['first', 'second']。不要使用 unshift()/shift() 在索引 0 处添加或移除元素。原始用户故事遗漏了这些调用约定和集合顺序要求;一个 pull request 更新了这些说明。
故障排除为什么 freeCodeCamp 后端课程的容器卡在 "Preparing the course" 界面,并出现 bash 报错 '$\r': command not found?
该错误是由于在 Windows 上(WSL 之外)克隆仓库时,Windows 风格的 CRLF(\r)行尾符被添加到了 ./bash/sourcerer.sh 和 ./bash/.bashrc 中。仓库文件本身使用的是 LF 行尾符,因此这是一个本地 Git 配置问题。修复方法:
1. 阻止 Git 转换行尾符,然后重新克隆仓库:
git config --global core.autocrlf false然后删除
back-end-development-and-apis 目录并重新克隆。
2. 或者在容器内移除受影响文件中的回车符:
sed -i 's/\r$//' ./bash/sourcerer.sh ./bash/.bashrc
你可以使用 sed -n 'l' ./bash/sourcerer.sh 来检查不可见字符。修复行尾符后,再次运行 freeCodeCamp: Run Course 命令——课程应该就能正常加载了。如果你在 Windows 上进行开发,在 WSL 内工作可以完全避免这个问题。
informational网站面包屑导航是基于网站层级结构,还是基于用户的浏览历史?
freeCodeCamp 课程中的面包屑(breadcrumbs)表示页面在网站层级结构中的位置,而不是用户的实际访问路径。例如,Home / Electronics / Phones / Smartphone XYZ 表示这些页面是网站结构中的父级栏目;直接从搜索结果进入的用户也应看到相同的路径。不要将面包屑链接描述为必然是"之前访问过的页面"。基于历史记录的面包屑会跟踪用户实际走过的路径,这是一种独立且较少见的模式,应明确标注为这种模式。主导航链接可能是指向嵌套分类的快捷方式,因此它们不必只对应顶级层级。请遵循 W3C ARIA 面包屑模式,并使用专门的 <nav> 元素(例如 <nav aria-label="Breadcrumb">)来呈现层级路径。