分享

Python os.join方法(用法详解)

 新用户5967EJDR 2021-01-04

本文整理汇总了后端语言Pythonos.join方法的典型用法及代码示例,这里的代码示例可能为您提供帮助。也可以进一步了解该方法所在模块os的用法示例。

如果想了解web前端内容,包括html,css,Javascript可以点击相关链接

示例1: update

# 需要导入模块: import os [as 别名]
# 或者: from os import join [as 别名]
def update(user, password, lang=None):
    langs = getlangs(lang)
    puts(u"Updating %s" % ', '.join(langs))
    for loc in langs:
        with indent(2):
            puts(u"Downloading PO for %s" % loc)
        url = (u'https://www./projects/p/formhub/'
               u'resource/django/l/%(lang)s/download/for_use/' % {'lang': loc})
        try:
            tmp_po_file = download_with_login(url, TX_LOGIN_URL,
                                              login=user, password=password,
                                              ext='po',
                                              username_field='identification',
                                              password_field='password',
                                              form_id=1)
            po_file = os.path.join(REPO_ROOT, 'locale', loc,
                                   'LC_MESSAGES', 'django.po')
            with indent(2):
                puts(u"Copying downloaded file to %s" % po_file)
            shutil.move(tmp_po_file, po_file)
        except Exception as e:
            puts(colored.red(u"Unable to update %s "
                             u"from Transifex: %r" % (loc, e)))
        puts(colored.green("sucesssfuly retrieved %s" % loc))
    compile_mo(langs)

示例2: saveGamepad

# 需要导入模块: import os [as 别名]
# 或者: from os import join [as 别名]
def saveGamepad(_settings):
    parser = SafeConfigParser()
    for controller_name in getSetting().getGamepadList():
        gamepad = getSetting(controller_name)
        if not parser.has_section(controller_name):
            parser.add_section(controller_name)
        for key,value in gamepad.key_bindings.axis_bindings.iteritems():
            neg,pos = value
            if not neg: neg = 'none'
            if not pos: pos = 'none'
            parser.set(controller_name,'a'+str(key),'('+str(neg)+','+str(pos)+')' )
        for key,value in gamepad.key_bindings.button_bindings.iteritems():
            parser.set(controller_name,'b'+str(key),str(value))
    with open(os.path.join(getSetting().datadir.replace('main.exe',''),'settings','gamepads.ini'), 'w') as configfile:
        parser.write(configfile)

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多