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
ch4ron
V2EX  ›  Python

关于 Python 的问题..

  •  
  •   ch4ron · 2019-07-26 17:42:19 +08:00 via Android · 963 次点击
    这是一个创建于 1707 天前的主题,其中的信息可能已经有所发展或是发生改变。
    3 条回复    2019-07-29 23:57:57 +08:00
    ch4ron
        1
    ch4ron  
    OP
       2019-07-26 17:44:10 +08:00 via Android
    就是 fileinput 的一个模块,当我:
    for line in fileinput.input('')
    line = line.replce()
    print(line,end='')
    的时候 line replace 进去的字符会乱码,有没有什么好的解决方法
    arrow8899
        2
    arrow8899  
       2019-07-26 21:38:49 +08:00
    for line in fileinput.input(openhook=fileinput.hook_encoded('your_encoding'))
    ch4ron
        3
    ch4ron  
    OP
       2019-07-29 23:57:57 +08:00 via Android
    @arrow8899 加了以后没效果..连内容都没替换
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1570 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 17:00 · PVG 01:00 · LAX 10:00 · JFK 13:00
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.