V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Skiro
V2EX  ›  Python

[求助] 请问如何利用 pypinyin 模块将汉字转为拼音后拼接至网址中?

  •  
  •   Skiro · 2020-04-12 17:52:59 +08:00 · 1898 次点击
    这是一个创建于 1447 天前的主题,其中的信息可能已经有所发展或是发生改变。

    如何利用 pypinyin 模块将汉字转为拼音后拼接至网址中?

    pompeii
        1
    pompeii  
       2020-04-12 17:56:25 +08:00
    为何不把两个 URL 打印出来看看呢
    lsvih
        2
    lsvih  
       2020-04-12 18:04:13 +08:00
    你这一个 202001.html 一个 index.html 肯定不会相等呀
    Skiro
        3
    Skiro  
    OP
       2020-04-12 18:19:11 +08:00
    不好意思,target_url 复制错了
    ```
    for year_month in range(201901,201903):
    data_url = "http://lishi.tianqi.com/"+str(Pinyin("北京"))+"/" + str(year_month) + ".html"
    ```
    爬每个月的天气数据总是报错
    Cursor1st
        4
    Cursor1st  
       2020-04-13 13:04:21 +08:00
    你把报错信息发一下
    Cursor1st
        5
    Cursor1st  
       2020-04-13 14:49:09 +08:00
    这是我运行的,是对的呀
    ![2020-04-13_144648.png]( )
    ![2020-04-13_144659.png]( )
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2939 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 11:08 · PVG 19:08 · LAX 04:08 · JFK 07:08
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.