首页 > 编程语言 > 详细

Python os.join方法(详解)

时间:2021-01-04 23:29:24      阅读:47      评论:0      收藏:0      [点我收藏+]

本文整理汇总了后端语言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.transifex.com/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) 

  

  

Python os.join方法(详解)

原文:https://www.cnblogs.com/c68ychen/p/14232778.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!