如何設(shè)置對 Windows 和 Unix 有效的語言環(huán)境(法語)?我的完整機(jī)器人測試是:*** Settings ***Library SeleniumLibraryLibrary DateTime*** Keywords ***Get Next Week French date Evaluate locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8') locale ${today}= Get Time ${tomorrow}= Add Time To Date ${today} 1 days ${three_day_after}= Add Time To Date ${today} 3 days ${today_day}= Convert Date ${today} result_format=%a Log To Console ${today_day} ${next_date}= Set Variable If "${today_day}"=="ven." ${three_day_after} ${tomorrow} ${next_week}= Add Time To Date ${next_date} 7 days ${day_of_week}= Convert Date ${next_week} result_format=%A ${day_of_week_fr}= Evaluate """${day_of_week}""".title() ${day}= Convert Date ${next_week} result_format=%d ${month}= Convert Date ${next_week} result_format=%B [Return] ${day_of_week_fr} ${day} ${month} test ${val}= Get Next Week French date Log To Console ${val}*** Test Cases ***MY SUPER TEST [Tags] foo|AC0 Given test在我的本地機(jī)器上(Windows 7)確定:Evaluate locale.setlocale(locale.LC_ALL, 'french') locale在我的 CI 機(jī)器(Unix)上可以:Evaluate locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8') locale如果我fr_FR.UTF-8在本地機(jī)器上使用,則會出現(xiàn)此錯誤:locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')' failed: unsupported locale setting編輯可能是 Python 2 (fr_FR.UTF-8) Vs。Python 3 (法語) ??
1 回答

慕斯709654
TA貢獻(xiàn)1840條經(jīng)驗 獲得超5個贊
由于 Windows 和 Unix 機(jī)器使用不同的語法來設(shè)置語言環(huán)境,因此您應(yīng)該首先評估操作系統(tǒng),然后相應(yīng)地設(shè)置語言環(huán)境。
*** Keywords ***
Get next week french date
${osName} Evaluate platform.system() platform
Run keyword if "${osName}"=='Windows' Evaluate locale.setlocale(locale.LC_ALL, 'french') locale
... ELSE Evaluate locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8') locale
添加回答
舉報
0/150
提交
取消