没有任何编程知识的小白 最近在自学 Python 学习 turtle 中
一开始是 Python 3.8.1
form turtle import *
color("red", "greed"}
shape("turtle")
done()
1
jdhao 2020-01-01 14:31:07 +08:00 via Android
|
2
dangyuluo 2020-01-01 14:55:56 +08:00
你第一句话(仅限空格之前)说的挺对的
|
3
victory OP @jdhao 新手不懂 V2EX 编辑器 误点击发布了 问题没有编辑好就发布出来了
没有任何编程知识的小白 最近在自学 Python 学习 turtle 中 一开始是 Python 3.8.1 x64 win10 x64 代码 ```Python form turtle import * color("red", "green") shape("turtle") done() ``` 参考文档 https://docs.python.org/zh-cn/3.8/library/turtle.html 运行报错 难道环境配置错了? 后来注册了 cloud studio 预置环境是 Python 2.7 x64 Ubuntu 代码 ```Python import turtle turtle.color("red", "green") turtle.shape("turtle") ``` 参考文档 https://docs.python.org/zh-cn/2.7/library/turtle.html 还是运行错误 我要裂开了 |
4
Sylv 2020-01-01 15:12:48 +08:00 via iPhone
运行报错请发报错信息,要不然让大家盲猜?
|
5
victory OP @Sylv
Python 3 的错误提示 ```Python Traceback (most recent call last): File "C:/Python/test.py", line 1, in <module> from turtle import * File "C:/Python\turtle.py", line 3, in <module> color("red", "blue") NameError: name 'color' is not defined ``` Python 2.7 的错误提示 ```Python cd /root/workspace ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /usr/bin/python /root/.local/share/code-server/extensions/ms-python.python-2019.6.24221/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 41197 /root/workspace/python2_turtle.py Traceback (most recent call last): File "/root/.local/share/code-server/extensions/ms-python.python-2019.6.24221/pythonFiles/ptvsd_launcher.py", line 43, in <module> main(ptvsdArgs) File "/root/.local/share/code-server/extensions/ms-python.python-2019.6.24221/pythonFiles/lib/python/ptvsd/__main__.py", line 434, in main run() File "/root/.local/share/code-server/extensions/ms-python.python-2019.6.24221/pythonFiles/lib/python/ptvsd/__main__.py", line 312, in run_file runpy.run_path(target, run_name='__main__') File "/usr/lib/python2.7/runpy.py", line 252, in run_path return _run_module_code(code, init_globals, run_name, path_name) File "/usr/lib/python2.7/runpy.py", line 82, in _run_module_code mod_name, mod_fname, mod_loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/root/workspace/python2_turtle.py", line 1, in <module> import turtle File "/usr/lib/python2.7/lib-tk/turtle.py", line 107, in <module> import Tkinter as TK File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in <module> raise ImportError, str(msg) + ', please install the python-tk package' ImportError: No module named _tkinter, please install the python-tk package ➜ workspace cd /root/workspace ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /usr/bin/python /root/.local/share/code-server/extensions/ms-python.python-2019.6.24221/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 48877 /root/workspace/python2_turtle.py Traceback (most recent call last): File "/root/.local/share/code-server/extensions/ms-python.python-2019.6.24221/pythonFiles/ptvsd_launcher.py", line 43, in <module> main(ptvsdArgs) File "/root/.local/share/code-server/extensions/ms-python.python-2019.6.24221/pythonFiles/lib/python/ptvsd/__main__.py", line 434, in main run() File "/root/.local/share/code-server/extensions/ms-python.python-2019.6.24221/pythonFiles/lib/python/ptvsd/__main__.py", line 312, in run_file runpy.run_path(target, run_name='__main__') File "/usr/lib/python2.7/runpy.py", line 252, in run_path return _run_module_code(code, init_globals, run_name, path_name) File "/usr/lib/python2.7/runpy.py", line 82, in _run_module_code mod_name, mod_fname, mod_loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/root/workspace/python2_turtle.py", line 1, in <module> import turtle File "/usr/lib/python2.7/lib-tk/turtle.py", line 107, in <module> import Tkinter as TK File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in <module> raise ImportError, str(msg) + ', please install the python-tk package' ImportError: No module named _tkinter, please install the python-tk package ``` |
8
zanelee 2020-01-01 15:46:22 +08:00
|
9
victory OP @zanelee 额 turtle 是内置模块 or 自带的标准库 不需要安装吧
Python3 为什么那么写 因为 官方参考文档就是那么写的 docs.python.org/zh-cn/3.8/library/turtle.html |
10
mochanight 2020-01-01 18:06:02 +08:00
import turtle
turtle.color("red", "green") turtle.shape("turtle") done() |
11
mochanight 2020-01-01 18:07:32 +08:00
import turtle
turtle.color("red", "green") turtle.shape("turtle") turtle.done() |
12
ylrshui 2020-01-01 18:37:51 +08:00 via iPhone
先 form -> from
|
13
yangzzzzzzzt1 2020-01-01 20:01:41 +08:00
( }
|