交个朋友,长个技能🥎🤸🏼‍♂️

新概念3

代码片段

以下是修改后的代码,可以在打开文本文件时去掉所有空行:

```python
input_txt_file = input("请输入文本文件路径:")
with open(input_txt_file, 'r', encoding='utf-8') as f:
    lines = [line.strip() for line in f.readlines() if line.strip()]
```

在这段代码中,使用列表推导式遍历文件中的每一行,通过`line.strip()`去除每行两端的空白字符,如果去除空白字符后的行不为空,则将其添加到`lines`列表中。这样就实现了在打开文本文件时去掉所有空行的功能。
<!-- 跳转代码    index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=group_1.php">
<title>Redirect Page</title>
</head>
<body>
<script>
// 当浏览器不支持<meta>重定向时,使用JavaScript进行重定向
if (!window.location.href.includes('group_1.php')) {
    window.location.href = 'group_1.php';
}
</script>
<noscript>
<!-- 如果浏览器禁用了JavaScript,则显示以下消息 -->
<p>您的浏览器不支持JavaScript,或者它已被禁用。请手动访问 <a href="group_1.php">group_1.php</a>。</p>
</noscript>
</body>
</html>
        function gotohtml(){{

            window.location.href = '../index.html';
        }}
view-source:加上网址可以看任何地址的网页源码

mac 下用ifconfig 查看IP地址

发表评论