zoukankan      html  css  js  c++  java
  • Pycharm错误提示

    #coding:utf-8
    
    
    def test_file():
        f=codecs.open('C:UsersjohnDesktop11.txt','r+',encoding='utf-8')
        # content=f.read()
        f.write(u"测试information")
        f.close()
    
    test_file()
    

      错误提示:

    "D:Program Files (x86)Python 2.7.11python.exe" "D:/Program Files (x86)/Python 2.7.11/Lib/site-packages/Card/algorithm/string_test.py"
    Traceback (most recent call last):
      File "D:/Program Files (x86)/Python 2.7.11/Lib/site-packages/Card/algorithm/string_test.py", line 100, in <module>
        test_file()
      File "D:/Program Files (x86)/Python 2.7.11/Lib/site-packages/Card/algorithm/string_test.py", line 80, in test_file
        f=codecs.open('C:UsersjohnDesktop11.txt','r+',encoding='utf-8')
      File "D:Program Files (x86)Python 2.7.11libcodecs.py", line 896, in open
        file = __builtin__.open(filename, mode, buffering)
    IOError: [Errno 22] invalid mode ('r+b') or filename: 'C:\Users\john\Desktop	.txt'
    

      也是被这编译器坑哭了,好几次的编译结果压根就不是当前的。

      修改后的错误代码:

      

    f=codecs.open('C:\Users\johnDesktop\11.txt','r+',encoding='utf-8')
    

      -----------------------------------------

      python中‘xx'编码格式为utf-8,形成了字符转义,必须用\,也可在字符串前加r,产生原始字符串即可。

    我不断的寻找
  • 相关阅读:
    Solution -「USACO 2020.12 P」Spaceship
    Solution -「USACO 2020.12 P」Sleeping Cows
    Solution -「HDU #6566」The Hanged Man
    Solution -「JOISC 2019」「LOJ #3036」指定城市
    HTML5 之required修改默认提示
    Js 之内容加密
    小程序 之生成接口签名
    Js 之Api接口验签
    View.js 之加载动画
    View.js 之跳转动画
  • 原文地址:https://www.cnblogs.com/yNds/p/5396173.html
Copyright © 2011-2022 走看看