首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >python3变量类型声明语法错误

python3变量类型声明语法错误
EN

Stack Overflow用户
提问于 2018-01-09 03:47:04
回答 2查看 396关注 0票数 0

为什么:语法不能在linux上工作?

On MacOS

代码语言:javascript
复制
→ python3
Python 3.6.3 (default, Oct  4 2017, 06:09:38) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x : str = "hello"
>>> 

On Linux

代码语言:javascript
复制
→ python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> x : str = "hello"
  File "<stdin>", line 1
    x : str = "hello"
      ^
SyntaxError: invalid syntax
>>> 
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-01-09 04:02:23

导致这种情况的是python的版本。在Linux上也更新到3.6。核对发布说明

3.6版有什么新鲜事

票数 1
EN

Stack Overflow用户

发布于 2018-01-09 03:54:46

这是python版本的问题所在。在linux中对3.6进行同样的尝试。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48161157

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档