老师,我点开run后就这样了,明明代码没错的呀,而且我之前点run运行这个代码也是很顺利的

老师,我点开run后就这样了,明明代码没错的呀,而且我之前点run运行这个代码也是很顺利的

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
好帮手慕凡 2022-08-11 09:40:12

同学,你好!

1、同学可以将代码全部截屏提交一下,看一下是否是代码中utf-8写为了utff-8,导致报错;

2、在python中不要以关键字或者模块名作为python的文件名;

祝学习愉快~

  • 提问者 6669ll #1

    C:\Users\31167\PycharmProjects\pythonProject1\venv\Scripts\python.exe C:/Users/31167/PycharmProjects/pythonProject1/main.py 

    Error processing line 1 of C:\Users\31167\PycharmProjects\pythonProject1\venv\lib\site-packages\_virtualenv.pth:


    Fatal Python error: init_import_size: Failed to import the site module

    Python runtime state: initialized

    Traceback (most recent call last):

      File "D:\python-3.8.1-amd64\lib\site.py", line 169, in addpackage

        exec(line)

      File "<string>", line 1, in <module>

      File "C:\Users\31167\PycharmProjects\pythonProject1\venv\lib\site-packages\_virtualenv.py", line 40, in <module>

        from functools import partial

      File "D:\python-3.8.1-amd64\lib\functools.py", line 17, in <module>

        from collections import namedtuple

      File "D:\python-3.8.1-amd64\lib\collections\__init__.py", line 22, in <module>

        from keyword import iskeyword as _iskeyword

      File "C:\Users\31167\PycharmProjects\pythonProject1\keyword.py", line 0

    SyntaxError: unknown encoding: utff-8


    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):

      File "D:\python-3.8.1-amd64\lib\site.py", line 580, in <module>

        main()

      File "D:\python-3.8.1-amd64\lib\site.py", line 563, in main

        known_paths = venv(known_paths)

      File "D:\python-3.8.1-amd64\lib\site.py", line 495, in venv

        addsitepackages(known_paths, [sys.prefix])

      File "D:\python-3.8.1-amd64\lib\site.py", line 350, in addsitepackages

        addsitedir(sitedir, known_paths)

      File "D:\python-3.8.1-amd64\lib\site.py", line 208, in addsitedir

        addpackage(sitedir, name, known_paths)

      File "D:\python-3.8.1-amd64\lib\site.py", line 179, in addpackage

        import traceback

      File "D:\python-3.8.1-amd64\lib\traceback.py", line 3, in <module>

        import collections

      File "D:\python-3.8.1-amd64\lib\collections\__init__.py", line 22, in <module>

        from keyword import iskeyword as _iskeyword

      File "C:\Users\31167\PycharmProjects\pythonProject1\keyword.py", line 0

    SyntaxError: unknown encoding: utff-8


    Process finished with exit code 1


    2022-08-18 12:40:19
  • 提问者 6669ll #2
    name = age =weight = __name__ ==:
        (name)
        (age)
        (weight)
        ((age))
        ((weight))
        (())
        (())
    os
    
    
    __name__ == :
        (os.getcwd())
    ()


    2022-08-18 12:41:55
  • 好帮手慕美 回复 提问者 6669ll #3

    同学,你好!

    1、同学提供的代码是乱码,可以将keyword.py文件中的代码截图一下

    2、keyword.py与系统文件重名,可以将文件名修改一下

    https://img1.sycdn.imooc.com//climg/62fdce13097ebbee05380169.jpg

    祝学习愉快!

    2022-08-18 13:28:54
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师