• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python minjson.read函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中z3c.json.minjson.read函数的典型用法代码示例。如果您正苦于以下问题:Python read函数的具体用法?Python read怎么用?Python read使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了read函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: testReadDictWithDoubleSlashComments

 def testReadDictWithDoubleSlashComments(self):
     s = """
     {'a':false,
       //  b:true, don't want b
     'c':true
     }
     """
     assert json.read(s) == {'a':False,'c':True}
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:8,代码来源:tests.py


示例2: testReadDictWithSlashStarComments

 def testReadDictWithSlashStarComments(self):
     s = """
     {'a':false,  /*don't want b
         b:true, */
     'c':true
     }
     """
     assert json.read(s) == {'a':False,'c':True}
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:8,代码来源:tests.py


示例3: read

 def read(self, aString, encoding=None):
     if hasCJson:
         try:
             # the True parameter here tells cjson to make all strings 
             # unicode. This is a good idea here.
             return cjson.decode(aString, True)
         except cjson.DecodeError:
             # fall back to minjson
             pass
     # This is a fall-back position for less-well-constructed JSON
     try:
         return minjson.read(aString, encoding)
     except minjson.ReadException, e:
         raise exceptions.ResponseError(e)
开发者ID:jean,项目名称:z3c.json,代码行数:14,代码来源:converter.py


示例4: testReadDictOfListsWithSpaces

 def testReadDictOfListsWithSpaces(self):
     s = u"{  'a' :    [],  'b'  : []  }    "
     assert json.read(s) == {'a':[],'b':[]}
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py


示例5: testReadEFloat2

 def testReadEFloat2(self):
     s = u"1.334E-02"
     assert json.read(s) == 0.01334
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py


示例6: testReadNegInt

 def testReadNegInt(self):
     s = u"-1"
     assert json.read(s) == -1
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py


示例7: testReadInt

 def testReadInt(self):
     s = u"1"
     self.assertEqual(json.read(s), 1)
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py


示例8: testReadString

 def testReadString(self):
     s = u"'hello'"
     self.assertEqual(json.read(s) ,'hello')
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py


示例9: testUnicodeFromNonUnicode

 def testUnicodeFromNonUnicode(self):
     obj = "'\u20ac'"
     r = json.read(obj)
     self.assertEqual(r, u'\u20ac')
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:4,代码来源:tests.py


示例10: readUBadJson

 def readUBadJson(self):
     s = ur"\u0027DOS\u0027*30"
     json.read(s)
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py


示例11: testReadStringWithEscapedSingleQuote

 def testReadStringWithEscapedSingleQuote(self):
     s = '"don\'t tread on me."'
     assert json.read(s) == "don't tread on me."
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py


示例12: testReadStringWithWhiteSpace

 def testReadStringWithWhiteSpace(self):
     s = ur"'hello \tworld'"
     assert json.read(s) == 'hello \tworld'
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py


示例13: testReadListOfStringsWithSpaces

 def testReadListOfStringsWithSpaces(self):
     s = u" ['a'    ,'b'  ,\n  'c']  "
     assert json.read(s) == ['a','b','c']
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py


示例14: testReadListOfDictsWithSpaces

 def testReadListOfDictsWithSpaces(self):
     s = u" [ {    } ,{   \n} ]   "
     assert json.read(s) == [{},{}]
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py


示例15: testReadListOfDicts

 def testReadListOfDicts(self):
     s = u"[{},{}]"
     assert json.read(s) == [{},{}]
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py


示例16: readClassExploit

 def readClassExploit(self):
     s = ur'''"__main__".__class__.__subclasses__()'''
     json.read(s)
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py


示例17: readBadJson

 def readBadJson(self):
     s = "'DOS'*30"
     json.read(s)
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py


示例18: testReadStringWithEscapedDoubleQuote

 def testReadStringWithEscapedDoubleQuote(self):
     s = r'"She said, \"Hi.\""'
     assert json.read(s) == 'She said, "Hi."'
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py


示例19: testReadEncodedUnicode

 def testReadEncodedUnicode(self):
     obj = "'La Peña'"
     r = json.read(obj, 'utf-8')
     self.assertEqual(r, unicode('La Peña','utf-8'))
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:4,代码来源:tests.py


示例20: testReadStringWithNewLine

 def testReadStringWithNewLine(self):
     s = r'"She said, \"Hi,\"\n to which he did not reply."'
     assert json.read(s) == 'She said, "Hi,"\n to which he did not reply.'
开发者ID:zopefoundation,项目名称:z3c.json,代码行数:3,代码来源:tests.py



注:本文中的z3c.json.minjson.read函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python minjson.write函数代码示例发布时间:2022-05-26
下一篇:
Python widget.FieldWidget类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap