当前位置: 首页>>代码示例>>Python>>正文


Python pythonapi.PyOS_ascii_formatd方法代码示例

本文整理汇总了Python中ctypes.pythonapi.PyOS_ascii_formatd方法的典型用法代码示例。如果您正苦于以下问题:Python pythonapi.PyOS_ascii_formatd方法的具体用法?Python pythonapi.PyOS_ascii_formatd怎么用?Python pythonapi.PyOS_ascii_formatd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ctypes.pythonapi的用法示例。


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

示例1: test_format

# 需要导入模块: from ctypes import pythonapi [as 别名]
# 或者: from ctypes.pythonapi import PyOS_ascii_formatd [as 别名]
def test_format(self):
        buf = create_string_buffer(' ' * 100)

        tests = [
            ('%f', 100.0),
            ('%g', 100.0),
            ('%#g', 100.0),
            ('%#.2g', 100.0),
            ('%#.2g', 123.4567),
            ('%#.2g', 1.234567e200),
            ('%e', 1.234567e200),
            ('%e', 1.234),
            ('%+e', 1.234),
            ('%-e', 1.234),
            ]

        with check_warnings(('PyOS_ascii_formatd is deprecated',
                             DeprecationWarning)):
            for format, val in tests:
                PyOS_ascii_formatd(byref(buf), sizeof(buf), format,
                                   c_double(val))
                self.assertEqual(buf.value, format % val) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,代码来源:test_ascii_formatd.py

示例2: test_format_deprecation

# 需要导入模块: from ctypes import pythonapi [as 别名]
# 或者: from ctypes.pythonapi import PyOS_ascii_formatd [as 别名]
def test_format_deprecation(self):
        buf = create_string_buffer(' ' * 100)

        with check_warnings(('PyOS_ascii_formatd is deprecated',
                             DeprecationWarning)):
            PyOS_ascii_formatd(byref(buf), sizeof(buf), '%+.10f',
                               c_double(10.0))
            self.assertEqual(buf.value, '+10.0000000000') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_ascii_formatd.py


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