Mô-đun
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale5 mở quyền truy cập vào cơ sở dữ liệu và chức năng địa phương POSIX. Cơ chế địa phương POSIX cho phép lập trình viên đối phó với một số vấn đề văn hóa trong một ứng dụng, mà không yêu cầu lập trình viên biết tất cả các chi tiết cụ thể của mỗi quốc gia nơi phần mềm được thực thi
Mô-đun
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale5 được khai triển trên đầu mô-đun
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale7, từ đó sử dụng khai thác cục bộ ANSI C nếu có
Mô-đun
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale5 xác định ngoại lệ và chức năng sauNgoại lệ ngoại lệ. lỗi¶ngôn ngữ. Lỗi¶
Ngoại lệ được nâng cấp khi địa chỉ được chuyển đến
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale9 không nhận đượcNgôn ngữ. setLocale [danh mục, locale = none] ¶setlocale[danh mục , ngôn ngữ=Không có]¶
Nếu Ngôn ngữ được đưa ra và không phải là
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale0, thì
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale9 sẽ sửa đổi cài đặt Ngôn ngữ cho danh mục. Các danh mục có sẵn được liệt kê trong mô tả dữ liệu dưới đây. Ngôn ngữ có thể là một chuỗi, hoặc có thể lặp lại hai chuỗi [mã ngôn ngữ và mã hóa]. Nếu nó có một sự khác biệt, thì nó đã chuyển đổi thành một tên địa phương bằng cách sử dụng động cơ bí danh địa phương. Một chuỗi trống chỉ định cài đặt mặc định của người dùng. Nếu việc sửa đổi địa chỉ không thành công, ngoại lệ
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale2 sẽ được nâng cấp. Nếu thành công, cài đặt địa chỉ mới được trả lại
Nếu Locale bị bỏ qua hoặc
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale0, cài đặt hiện tại cho danh mục sẽ được trả lại
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale9 không an toàn cho hầu hết các hệ thống. Các ứng dụng thường bắt đầu bằng một cuộc gọi
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale0
Điều này đặt ngôn ngữ cho tất cả các danh mục cài đặt mặc định của người dùng [thường được chỉ định trong môi trường biến
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale2]. Nếu địa điểm không thay đổi sau đó, việc sử dụng đa luồng sẽ không gây ra vấn đề. Biến môi trường
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale2]. Nếu ngôn ngữ không bị thay đổi sau đó, việc sử dụng đa luồng sẽ không gây ra sự cố. Ngôn ngữ. localeconv [] ¶localeconv[]¶
Trả về cơ sở dữ liệu của các quy ước địa phương như một từ điển. Từ điển này có các chuỗi sau làm khóa
Loại
Key key
Nghĩa
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale3____04
Dãy phân tích ký tự
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale5
Trình tự các số chỉ định vị trí tương đối mà
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale6 dự kiến. If the string was terminating with
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale7, does not have any group are done more. Nếu chuỗi kết thúc với
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale8, kích thước nhóm cuối cùng được sử dụng nhiều lần.
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale6
Nhân vật được sử dụng giữa các nhóm
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale50
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale51
Biểu tượng tiền tệ quốc tế
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale52
local icon
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale53
Liệu ký hiệu tiền tệ có đi trước giá trị [đối lập với các giá trị âm dương tích cực]
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale54
Cho dù ký hiệu tiền tệ được tách ra khỏi giá trị bằng một khoảng trống [cho các giá trị âm tích cực]
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale55
Các điểm phân tích được sử dụng cho các giá trị tiền tệ
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale56
Số lượng các chữ số phân số được sử dụng trong định dạng cục bộ của các giá trị tiền tệ
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale57
Số lượng các chữ số phân số được sử dụng trong định dạng quốc tế của các giá trị tiền tệ
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale58
Phân chia nhóm được sử dụng cho các giá trị tiền tệ
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale59
Tương thích với
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale5, được sử dụng cho các loại tiền tệ có giá trị
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale51
Các biểu tượng được sử dụng để giải thích giá trị tiền tệ tích cực
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale52
Các biểu tượng được sử dụng để giải thích giá trị tiền tệ
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale53
Vị trí của dấu hiệu [cho các giá trị tiêu cực tích cực], xem bên dưới
Tất cả các giá trị có thể được đặt thành
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale7 để chỉ ra rằng không có giá trị được định nghĩa duy nhất trong ngôn ngữ này
Các giá trị có thể cho
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale55 và
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale56 được đưa ra dưới đây
value
Giải thích chương trình
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale8
Tiền tệ và giá trị được bao quanh bởi dấu ngoặc đơn
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale58
Dấu hiệu sẽ đi trước giá trị và ký hiệu tiền tệ
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale59
Dấu hiệu phải theo biểu tượng giá trị và tiền tệ
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale70
Dấu hiệu phải ngay trước giá trị
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale71
Dấu hiệu nên lập tức làm theo giá trị
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale7
Không có gì được chỉ định trong địa chỉ này
The temporate time
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale73 to language
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale3 hoặc địa phương
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale50 nếu các địa phương khác nhau và các chuỗi tiền tệ hoặc tiền tệ không phải là ASCII. Thay đổi tạm thời ảnh hưởng này đến các chủ đề khác
Changed in version 3. 7. Hàm tạm thời set locale >>> import locale
>>> loc = locale.getlocale[] # get current locale
# use German locale; name might vary with platform
>>> locale.setlocale[locale.LC_ALL, 'de_DE']
>>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut
>>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale
>>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale
>>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale
73 to language
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale3 in a field HỢP SỐ. Hàm hiện tạm thời đặt ngôn ngữ
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale73 thành ngôn ngữ ____03 trong một số trường hợp. Ngôn ngữ. nl_langinfo [tùy chọn] ¶nl_langinfo[tùy chọn]¶
Trả về một số thông tin cụ thể về địa chỉ dưới dạng chuỗi. Hàm này không có sẵn trên tất cả các hệ thống và tập hợp các tùy chọn tùy chọn cũng như có thể thay đổi giữa các nền tảng nền tảng. Các giá trị đối số có thể là các số, trong đó các hằng số biểu tượng có sẵn trong mô-đun địa phương
Hàm
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale78 chấp nhận một trong các khóa sau. Hầu hết các mô tả được lấy từ mô tả tương ứng trong thư viện GNU CNgôn ngữ. Bộ mã¶CODESET¶
Nhận một chuỗi có tên của ký tự mã hóa được sử dụng trong ngôn ngữ đã chọn
Ngôn ngữ. D_T_FMT¶D_T_FMT¶got a string could be used as a string format for
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale79 to expression the date and time by the tool of languageNgôn ngữ. D_FMT¶D_FMT¶
got a string could be used as a string format for
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale79 to expression an day by the tool of languageNgôn ngữ. T_FMT¶T_FMT¶
got a string could be used as a string format for
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale79 to expression a time time by the tool of languageNgôn ngữ. T_FMT_AMPM¶T_FMT_AMPM¶
Get an a string format for
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale79 to icon time in format AM/pmDAY_1. NGÀY_7 . DAY_7
Lấy tên của ngày thứ n trong tuần
Ghi chú
Điều này theo Công ước Hoa Kỳ về việc
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale53 là Chủ nhật, chứ không phải Công ước quốc tế [ISO 8601] rằng Thứ Hải là ngày đầu tiên của tuầnABDAY_1. ABDAY_7 . ABDAY_7
Nhận tên viết tắt của ngày thứ n trong tuần
MON_1. MON_12 . MON_12Lấy tên của tháng n
ABMON_1. ABMON_12 . ABMON_12Nhận tên viết tắt của tháng n
Ngôn ngữ. Radixchar¶RADIXCHAR¶Resigned character radix [dấu chấm thập phân, dấu thập phân, v. v. ]
Ngôn ngữ. ThouseP¶NHÀ NHÀ¶Nhận các ký tự phân tách cho hàng nghìn [nhóm ba chữ số]
Ngôn ngữ. yesexpr¶YESEXPR¶Nhận một biểu thức thông thường có thể được sử dụng với hàm regex để nhận phản hồi tích cực cho câu hỏi có/không
Nhận một biểu thức thông thường có thể được sử dụng với hàm regex [3] để nhận phản hồi tiêu cực đối với câu hỏi có/không
Ghi chú
Điều này theo Công ước Hoa Kỳ về việc
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale53 là Chủ nhật, chứ không phải Công ước quốc tế [ISO 8601] rằng Thứ Hải là ngày đầu tiên của tuầnNhận tên viết tắt của ngày thứ n trong tuần. CRNCYSTR¶
Lấy tên của tháng n
Nhận tên viết tắt của tháng n. Kỷ nguyên¶địa phương. Cơ số¶
Resigned character radix [dấu chấm thập phân, dấu thập phân, v. v. ]
địa phương. ThouseP¶
Nhận ký tự phân tách cho hàng nghìn [nhóm ba chữ số]. ERA_D_T_FMT¶địa phương. yesexpr¶
Nhận một biểu thức thông thường có thể được sử dụng với hàm regex để nhận phản hồi tích cực cho câu hỏi có/không. ERA_D_FMT¶địa phương. Không có Expr¶
Nhận một biểu thức thông thường có thể được sử dụng với hàm regex [3] để nhận phản hồi tiêu cực đối với câu hỏi có/không. ERA_T_FMT¶Các biểu thức chính quy cho cú pháp
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale54 và
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale55 sử dụng cú pháp phù hợp cho hàm
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale56 từ thư viện C, có thể khác với cú pháp được sử dụng trong
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale57Ngôn ngữ. crncystr¶ALT_DIGITS¶
Nhận biểu tượng tiền tệ, trước đó là--Nếu biểu tượng sẽ xuất hiện trước giá trị, thì ++ nếu biểu tượng sẽ xuất hiện sau giá trị, hoặc. Nếu biểu tượng nên thay thế các ký tự cơ số
Ngôn ngữ. era¶getdefaultlocale[[envvars]]¶Get an a character string for ERA are used in the current language at
Hầu hết các địa chỉ không xác định giá trị này. Một ví dụ về một địa điểm xác định giá trị này là giá trị của Nhật Bản. Tại Nhật Bản, đại diện truyền thống của ngày bao gồm tên của thời đại tương ứng với triều đại của hoàng đế
biến>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale2. Vì chúng tôi không muốn can thiệp vào cài đặt ngôn ngữ hiện tại, do đó, chúng tôi mô phỏng hành vi theo cách được mô tả ở trên
Thông thường không cần thiết phải sử dụng giá trị này trực tiếp. Chỉ công cụ sửa đổi công cụ
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale58 trong chuỗi định dạng của chúng làm hàm
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale79 sử dụng thông tin này. Định dạng của chuỗi được trả về không phải là định dạng duy nhất và do đó bạn không nên cho rằng ý kiến về nó trên các hệ thống khác nhauBiến
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale2 được kiểm tra, nhưng danh sách các biến được cung cấp dưới dạng tham số envvars. Cái đầu tiên được tìm thấy được xác định sẽ được sử dụng. envvars mặc định cho đường dẫn tìm kiếm được sử dụng trong GNU gettext; . Đường dẫn tìm kiếm văn bản GNU chứa
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale00,
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale01,
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale99 và
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale03, theo thứ tự đó
địa phương. era_d_t_fmt¶RFC 1766. mã ngôn ngữ và mã hóa có thể là
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale0 nếu không xác định được giá trị của chúng
Get an string format for >>> import locale
>>> loc = locale.getlocale[] # get current locale
# use German locale; name might vary with platform
>>> locale.setlocale[locale.LC_ALL, 'de_DE']
>>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut
>>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale
>>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale
>>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale
79 to expression the date and time by the way based on the current address
Get a format string for
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale79 to expression a day on the way based on the current address
địa phương. era_d_t_fmt¶RFC 1766. mã ngôn ngữ và mã hóa có thể là
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale0 nếu không xác định được giá trị của chúngNhận dạng chuỗi định dạng cho
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale79 để biểu thị ngày và thời gian theo cách dựa trên địa phương thời đại. getpreferredencoding[do_setlocale=Đúng]¶
Ngôn ngữ. era_d_fmt¶ mã hóa ngôn ngữ được sử dụng cho dữ liệu văn bản, theo tùy chọn của người dùng. Các tùy chọn của người dùng được thể hiện khác nhau trên các hệ thống khác nhau và có thể không có sẵn theo chương trình trên một số hệ thống, vì vậy chức năng này chỉ trả về kết quả đoán.
Get a format string for
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale79 to expression a day on the way based on the current address
Ngôn ngữ. era_t_fmt¶ Chế độ Python UTF-8 được bật, luôn trả về
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale93, mã hóa ngôn ngữ and the do_setlocale argument are ignored.
Tiền đề Python được định cấu hình địa phương LC_CTYPE. Xem thêm mã hóa hệ thống tập tin và xử lý lỗi. Khởi tạo trước Python định cấu hình ngôn ngữ LC_CTYPE. Xem thêm mã hóa hệ thống tệp và trình xử lý lỗi .
Đã thay đổi trong phiên bản 3. 7. Hàm bây giờ luôn trả về >>> import locale
>>> loc = locale.getlocale[] # get current locale
# use German locale; name might vary with platform
>>> locale.setlocale[locale.LC_ALL, 'de_DE']
>>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut
>>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale
>>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale
>>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale
94 trên Android hoặc nếu chế độ Python UTF-8 được bật. Hàm hiện luôn trả về
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale94 trên Android hoặc nếu Chế độ Python UTF-8 được bật. ngôn ngữ. getencoding [] ¶getencoding[]¶
Nhận mã hóa ngôn ngữ hiện tại. mã hóa ngôn ngữ .
Trên Android và VxWorks, trả lại
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale
94Trên UNIX, trả lại mã hóa của địa phương
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale
73 hiện tại. Trả về>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale
94 Nếu>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale
98 trả về một chuỗi trống. Ví dụ. if locale lc_ctype hiện không được hỗ trợOn Windows, return ANSI code
Tiền đề Python được định cấu hình địa phương LC_CTYPE. Xem thêm mã hóa hệ thống tập tin và xử lý lỗi. Khởi tạo trước Python định cấu hình ngôn ngữ LC_CTYPE. Xem thêm mã hóa hệ thống tệp và trình xử lý lỗi .
Hàm này tương tự như
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale99 Hàm ngoại trừ hàm này bỏ qua chế độ UTF-8 Python. Chế độ Python UTF-8 .
New in version 3. 11
Ngôn ngữ. Chuẩn hóa [LocalEname] ¶chuẩn hóa[tên ngôn ngữ]¶Trả về mã địa phương đã được chuẩn hóa cho tên địa phương đã chọn. Mã địa phương được trả về được định dạng để sử dụng với
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale9. Nếu quá trình hóa không thành công, tên ban đầu được trả về không thay đổi
Nếu mã hóa đã chọn không được biết, hàm mặc định là mã hóa mặc định cho mã ngôn ngữ giống như
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale9Ngôn ngữ. ResetLocale [Thể loại = LC_ALL] ¶resetlocale[danh mục=LC_ALL]¶
Set Locale for list to setting default
Mặc định cài đặt được xác định bằng cách gọi
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale22. default item is
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale07
Not used more than from version 3. 11, will be delete in version 3. 13
Ngôn ngữ. strcoll [String1, String2] ¶strcoll[string1 , string2]¶So sánh hai chuỗi theo cài đặt
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale24 hiện tại. Như bất kỳ hàm so sánh nào khác, trả về một giá trị âm hoặc giá trị dương hoặc
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale8, tùy thuộc vào công việc String1 đối chiếu trước hoặc sau chuỗi2 hoặc bằng với nó. Ngôn ngữ. strxfrm [Chuỗi] ¶strxfrm[chuỗi]¶
Chuyển đổi một chuỗi thành một chuỗi có thể được sử dụng trong các so sánh nhận biết địa phương. Ví dụ,
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale26 tương đương với
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale27. Hàm này có thể được sử dụng khi cùng một chuỗi được so sánh nhiều lần, ví dụ. Khi đối chiếu một chuỗi các chuỗingôn ngữ. format_string [định dạng, val, nhóm = false, tiền tệ = false] ¶format_string[định dạng , val , nhóm=Sai , tiền tệ=Sai]¶
Định dạng một số Val theo cài đặt
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale3 hiện tại. Định dạng nhiệm vụ theo các quy định của toán tử
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale29. Đối với các giá trị nổi, điểm thập phân được sửa đổi nếu thích hợp. Nếu nhóm là
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale00, cũng sẽ tính đến công việc của nhóm
Nếu tiền tệ là đúng, việc chuyển đổi sử dụng chuỗi hàng ngàn tiền tệ và nhóm chuỗi
Các định dạng quy định của các nhà xác định như trong
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale01, nhưng tính đến địa chỉ cài đặt hiện tại
Thay đổi trong phiên bản 3. 7. Tham số từ khóa tiền tệ đã được thêm vào. Tham số từ khóa tiền tệ đã được thêm vào.
ngôn ngữ. định dạng [định dạng, val, nhóm = false, tiền tệ = false] ¶định dạng[định dạng , val , nhóm=Sai , tiền tệ=Sai]¶Xin lưu ý rằng chức năng này hoạt động như
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale02 nhưng sẽ chỉ kích hoạt cho một trình xác định chính xác_______003. Ví dụ,
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale04 và
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale05 đều là các nhà xác định hợp lệ, nhưng
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale06 thì không
Đối chiếu với định dạng toàn bộ chuỗi, sử dụng
____002. Ngôn ngữ. Tiền tệ [Val, Ký hiệu = true, nhóm = false, quốc tế = false] ¶tiền tệ[val , ký hiệu=Đúng , nhóm=Sai , quốc tế=Sai]¶Định dạng một số Val theo cài đặt
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale50 hiện tại
Chuỗi được trả về bao gồm ký hiệu tiền tệ nếu biểu tượng là đúng, đó là mặc định. If the group is
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale00 [không phải là mặc định], group is done with value. Nếu quốc tế là
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale00 [không phải là mặc định], biểu tượng tiền tệ quốc tế được sử dụng
Ghi chú
Chức năng này sẽ không hoạt động với ngôn ngữ 'C, vì vậy bạn phải đặt một ngôn ngữ thông qua
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale9 trướcNgôn ngữ. str [Nổi] ¶str[phao]¶
Định dạng một số điểm nổi sử dụng cùng một định dạng với hàm phân tích
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale12, but tính đến thập phân. ngôn ngữ. delocalize [chuỗi] ¶delocalize[chuỗi]¶
Chuyển đổi một chuỗi thành một chuỗi số đã được chuẩn hóa, theo cài đặt
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale3
New in version 3. 5
ngôn ngữ. locize [chuỗi, group = false, money tệ = false] ¶bản địa hóa[chuỗi , nhóm=Sai , tiền tệ=Sai]¶Chuyển đổi một chuỗi số đã được chuẩn hóa thành một chuỗi được định dạng theo cài đặt
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale3
New in version 3. 10
Ngôn ngữ. atof [Chuỗi, func = float] ¶atof[chuỗi , func=phao]¶Move a string to a number, theo cài đặt
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale3, by way call func about results call_______016 on string. Ngôn ngữ. atoi [Chuỗi] ¶atoi[chuỗi]¶
Move a string to a integer, by the rules
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale3. Ngôn ngữ. lc_ctype¶LC_CTYPE¶
Danh mục địa chỉ cho các loại ký tự chức năng. Tùy thuộc vào cài đặt của danh mục này, chức năng của mô-đun
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale18 xử lý trường hợp thay đổi hành vi của họ. Ngôn ngữ. lc_collate¶LC_COLLATE¶
The type of address to phan loại chuỗi. Các chức năng
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale19 và
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale20 của mô-đun
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale5 bị ảnh hưởng. Ngôn ngữ. lc_time¶LC_TIME¶
Loại địa phương cho định dạng thời gian. Hàm
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale79 chịu trách nhiệm theo các quy ước nàyNgôn ngữ. lc_monetary¶LC_MONETARY¶
Loại địa chỉ để định dạng các giá trị tiền tệ. Các tùy chọn có sẵn có sẵn từ chức năng
____023. Ngôn ngữ. LC_Messages¶LC_MESSAGES¶Danh mục địa chỉ để hiển thị tin nhắn. Python hiện không hỗ trợ các tin nhắn nhận biết địa chỉ cụ thể của ứng dụng. Tin nhắn được hiển thị bởi hệ điều hành, giống như tin nhắn được trả về bởi
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale24 may be bị ảnh hưởng bởi danh mục này. Ngôn ngữ. lc_numeric¶LC_NUMERIC¶
Danh mục địa chỉ để định dạng số. Các hàm
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale25,______026,
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale27 và
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale28 của mô-đun
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale5 bị ảnh hưởng bởi danh mục đó. Tất cả các định dạng định dạng hoạt động khác đều không bị ảnh hưởng. Ngôn ngữ. lc_all¶LC_ALL¶
Kết hợp tất cả các địa chỉ cài đặt. Nếu cờ này được sử dụng khi địa điểm bị thay đổi, hãy đặt địa điểm cho tất cả các danh mục đã được thử nghiệm. Nếu điều đó thất bại đối với bất kỳ danh mục nào, không có danh mục nào được thay đổi. Khi ngôn ngữ được truy xuất bằng cờ này, một chuỗi chỉ được cài đặt cho tất cả các danh mục được trả về. This string after that could be used to khôi phục cài đặt
Ngôn ngữ. char_max¶CHAR_MAX¶Đây là hằng số biểu tượng được sử dụng cho các giá trị khác nhau được trả về bởi
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale23
Thí dụ
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale
Bối cảnh, chi tiết, gợi ý, lời khuyên và cảnh báo
Định nghĩa tiêu chuẩn C Định nghĩa Ngôn ngữ là một thuộc tính toàn chương trình có thể tương thích với các đối tượng kém để thay đổi. Trên hết, một số phát triển bị phá vỡ theo cách mà các thay đổi địa phương thông thường có thể gây ra các khoảng trống lõi. Điều này làm cho địa điểm hơi đau khi sử dụng chính xác
Ban đầu, khi một chương trình được bắt đầu, ngôn ngữ là địa phương
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale31, bất kể người dùng thích địa phương là gì. Có một ngoại lệ. danh mục
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale73 đã được thay đổi khi khởi động để đặt mã hóa ngôn ngữ hiện tại cho mã hóa ngôn ngữ ưa thích của người dùng. Chương trình phải nói rõ ràng rằng nó muốn cài đặt địa chỉ ưa thích của người dùng cho các danh mục khác bằng cách gọi
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale94
Nói chung, đó là một ý tưởng hoang tưởng để gọi
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale9 trong một số thói quen thư viện, vì là một tác dụng phụ, nó ảnh hưởng đến toàn bộ chương trình. Tiết kiệm và phục hồi nó gần như xấu. Nó trả tiền và ảnh hưởng đến các chủ đề khác xảy ra trước khi cài đặt được khôi phục
Nếu, khi mã hóa một mô-đun để sử dụng chung, bạn cần một phiên bản độc lập địa phương của một hoạt động bị ảnh hưởng bởi ngôn ngữ [chẳng hạn như các định dạng định dạng nhất được sử dụng với
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale79], bạn sẽ . Thậm chí tốt hơn là thuyết phục bản thân rằng sử dụng cài đặt địa phương là ổn. Chỉ giống như là cuối cùng của phương pháp, bạn mới ghi nhận rằng mô-đun của bạn không tương thích với các cài đặt địa phương không phải là -____ 131
Cách duy nhất để thực hiện các số hoạt động theo ngôn ngữ là sử dụng các chức năng đặc biệt được xác định bởi mô-đun này
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale27,
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale26,
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale25,
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale28
Không có cách nào để thực hiện chuyển đổi trường hợp và phân loại ký tự theo địa chỉ. Đối với các chuỗi văn bản [unicode], chúng chỉ được thực hiện theo các ký tự giá trị, trong khi đối với chuỗi byte, các chuyển đổi và phân loại được thực hiện theo giá trị ASCII của byte và byte có bit cao được đặt
Cho các nhà văn và chương trình nhúng Python¶ mở rộng
Các mô-đun mở rộng không bao giờ nên gọi là
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale9, ngoại trừ để tìm hiểu địa chỉ hiện tại là gì. Nhưng vì giá trị trả lại chỉ có thể được sử dụng một cách xác định để khôi phục nó, điều đó không hữu ích lắm [ngoại trừ có thể để tìm hiểu xem địa phương có phải là
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale31]
Khi mã Python sử dụng mô-đun -mô-đun
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale5 để thay đổi ngôn ngữ, điều này cũng ảnh hưởng đến ứng dụng nhúng. Nếu ứng dụng nhúng không muốn điều này xảy ra, nó sẽ xóa mô-đun mở rộng
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale7 [thực hiện tất cả các công việc] khỏi bảng các mô-đun tích hợp trong tệp
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale45 và chắc chắn rằng mô-đun
>>> import locale >>> loc = locale.getlocale[] # get current locale # use German locale; name might vary with platform >>> locale.setlocale[locale.LC_ALL, 'de_DE'] >>> locale.strcoll['f\xe4n', 'foo'] # compare a string containing an umlaut >>> locale.setlocale[locale.LC_ALL, ''] # use user's preferred locale >>> locale.setlocale[locale.LC_ALL, 'C'] # use default [C] locale >>> locale.setlocale[locale.LC_ALL, loc] # restore saved locale7 không thể truy cập được một thư viện được chia sẻ
Truy cập vào Danh mục Tin nhắn
ngôn ngữ. gettext [tin nhắn] ¶ Ngôn ngữ. DgetText [tên miền, tin nhắn] ¶ Ngôn ngữ. DcgetText [tên miền, tin nhắn, danh mục] ¶ Ngôn ngữ. TextDomain [miền]gettext[tin nhắn]¶ locale.dgettext[tên miền , tin nhắn . ]¶ locale.dcgettext[tên miền , tin nhắn . , category]¶ locale.miền văn bản[miền] ¶ . locale.miền liên kết văn bản[miền , dir]¶Mô-đun Địa điểm hiển thị giao diện GetText thư viện C trên các hệ thống cung cấp giao diện này. Nó bao gồm các chức năng