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


Python IDF.idfname方法代码示例

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


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

示例1: test_savecopy

# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import idfname [as 别名]
def test_savecopy():
    """Test the IDF.savecopy() function.
    """
    file_text = "Material,TestMaterial,  !- Name"
    idf = IDF(StringIO(file_text))
    idf.idfname = 'test.idf'

    try:
        idf.savecopy()  # this should raise an error as no filename is passed
        assert False
    except TypeError:
        pass

    file_handle = StringIO()
    idf.savecopy(file_handle)  # save a copy with a different filename
    expected = "TestMaterial"
    file_handle.seek(0)
    result = file_handle.read()
    assert expected in result

    # test the idfname attribute has not been changed
    assert idf.idfname == 'test.idf'
开发者ID:santoshphilip,项目名称:eppy,代码行数:24,代码来源:test_modeleditor.py

示例2: StringIO

# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import idfname [as 别名]
idftxt = "VERSION, 7.3;" # Not an emplty string. has just the version number
fhandle = StringIO(idftxt) # we can make a file handle of a string
idf_notemptyfile = IDF(fhandle) # initialize the IDF object with the file handle

idf_notemptyfile.printidf()

# <markdowncell>

# Aha !
# 
# Now let us give it a file name

# <codecell>

# - give it a file name
idf_notemptyfile.idfname = "notemptyfile.idf"
# - Save it to the disk
idf_notemptyfile.save()

# <markdowncell>

# Let us confirm that the file was saved to disk

# <codecell>

txt = open("notemptyfile.idf", 'r').read()# read the file from the disk
print(txt)

# <markdowncell>

# Yup ! that file was saved. Let us delete it since we were just playing
开发者ID:Nobatek,项目名称:eppy,代码行数:33,代码来源:newfunctions.py


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