Comments (6)
from blogs.
糊了一个生成脚本 https://github.com/ustclug/blogs/blob/master/opml.py
from blogs.
糊了一个生成脚本 https://github.com/ustclug/blogs/blob/master/opml.py
我用的 Thunderbird 102.6.1 (Windows 10),似乎生成的 OPML 文件并不能成功导入 Thunderbird (会提示“文件 opml.opml 似乎不是一个有效的 OPML 文件。”)
另外,在 Windows (& cp936)下默认字符编码是 gbk,可能最好在 open 那里指定一下
diff --git a/opml.py b/opml.py
index e85f368..6309d85 100644
--- a/opml.py
+++ b/opml.py
@@ -17,7 +17,7 @@ def check(rssurl):
def main(args):
contents = []
# 1. Parse README.md and get the list of links
- with open("./README.md") as f:
+ with open("./README.md", encoding="utf-8") as f:
for line in f:
if line.startswith("|"):
try:
from blogs.
Thunderbird 导入不了的原因是 Windows 下 python opml.py --thunderbird > opml.opml
得到的 opml.opml
是 UTF-16 的文件,但是 Thunderbird(至少在 Linux 下)只吃 UTF-8。
open()
的 encoding 已经在 898f537 加了。
from blogs.
加上了 sys.stdout.reconfigure(encoding='utf-8')
之后,Python 在 Windows console 下文件重定向的行为是:
- cmd.exe: UTF-8
- powershell.exe(自带版本): UTF-16
- PowerShell 6+: 根据这里的说法是 UTF-8
所以还是只能把脚本改成默认输出文件了。
from blogs.
现在在 Windows 10 + cp936 下面可以啦,感谢
from blogs.
Related Issues (7)
- 想要加入0v0 HOT 1
- 可以推荐别人的 blog 吗? HOT 1
- Wanna join ^_^ HOT 1
- 求帮加一个 hhh HOT 1
- Hustcw is down
- add luojh's blogs HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blogs.