支持的 Python 命令和包#
核心命令#
Python 3.8 中包含的所有内置命令、函数、常量、类型和异常都可以在 VEXcode VR 中使用。
参考:
还支持字符串操作、正则表达式和文本换行等核心组件。
参考:
Available Packages#
The following packages are fully supported and can be imported into VEXcode VR so they can be used in coding projects. To do so, use the keyword import
followed by the name of the package you want to import at the beginning of your coding project.
支持的软件包:
-
Note: The
sleep
command from this package is not compatible with VEXcode VR.
-
Note: Any code that prints directly using the
pprint
package will not be displayed in the VEXcode VR Print Console.
Preferred Installer Program (PIP) and micropip#
It is not possible to use PIP to install packages to VEXcode VR due to it being based entirely within the web browser. You can use micropip
to import packages written purely in Python, but the packages will not work if they attempt to access hardware or use other unsupported features.
由于可用软件包的数量,我们无法提供可在 VEXcode VR 中运行的软件包列表。
import micropip
def main():
# Tell micropip to install the "snowballstemmer" package.
await micropip.install('snowballstemmer')
# Now that "snowballstemmer" is installed, we can import the
# package.
import snowballstemmer
# Use the package to find the stems of the words and print
# them.
stemmer = snowballstemmer.stemmer('english')
brain.print(stemmer.stemWords('go goes going gone'.split()))
vr_thread(main)
Known Unsupported Features / Packages#
并发执行#
The native Python options for concurrent execution are not supported in VEXcode VR. This is due to security features in the browser and other web technologies used with VEXcode to prevent malicious access to your computer. VEXcode instead uses the vr_thread
command to create a simplified thread for running things concurrently.
不受支持的软件包组#
There are many Python packages that can be imported using the import
keyword, but will not be supported in VEXcode VR.
VEXcode VR 不支持的 Python 软件包组:
文件系统或外部应用程序通信。
网络或进程间通信。
需要图形的包。
多媒体显示或播放包。
除 micropip 之外的包,用于导入其他包。
特定于操作系统的软件包或那些改变操作系统设置的软件包。
Python 运行时包。
专用于管理或构建 Python 包和开发工具的包。