01无效令牌 [英] 01 invalid token

查看:68
本文介绍了01无效令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,学习python3已有一段时间了.

Hey been learning python3 for a while.

熟悉字典和dictionary_name.get()方法,并尝试获取随机键值.

Came across dictionaries and the dictionary_name.get() method and tried to get a random key value.

问题:

data= {}

data.get('key',1)

它有效,并且返回1

但是,如果我使用data.get('key',01),它会说无效令牌,为什么呢?

But instead if I use data.get('key',01) it says invalid token why is that?

推荐答案

在Python 2.x中,以0开头的整数文字被解释为八进制数字.在Python 3.x中,八进制数写为前缀0o.为了避免旧代码更改的含义而没有任何警告,仅以0开头的文字现在是语法错误.

In Python 2.x, integer literals starting with 0 were interpreted as octal numbers. In Python 3.x, octal numbers are written with the prefix 0o instead. To avoid that old code changes meaning without any warning, literals starting with just 0 are a syntax error now.

这篇关于01无效令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆