# Python3 데모 코드
#
# maketrans() 및 translate()
# uk 문자 번역 설정
<코드 클래스 = "일반"> str1 <코드 클래스 = "키워드"> = <코드 클래스 = "문자열"> " wy "
# 로 대체하도록 지정 str2 <코드 클래스 = "키워드"> = <코드 클래스 = "문자열"> "gf"
<코드 클래스 = " comment"> # 문자 제거
str3 = "u"
# 대상 t 문자열
trg = "weeksyourweeks"
# maketrans() for
# 빌드 번역
# 테이블 탭 파일 = trg.maketrans (str1, str2, str3)
# 원본 줄 인쇄
print ( "번역하기 전의 문자열은:" <코드 클래스 = "일반">, 끝 <코드 클래스 = "키워드"> = <코드 클래스 = "일반"> "")
인쇄 (trg)
< br> # 번역을 위해 translate()를 사용합니다.
print ( "번역 후 문자열 " , end = " ") < / p>
인쇄 (trg.translate (테이블)) 출력: 번역 전의 문자열은 다음과 같습니다. weekyourweeks 번역 후의 문자열은 다음과 같습니다. pythonengineering layouttrans() 없이 번역 번역 사전을 지정하고 디스플레이 역할을 하는 객체로 전달하여 번역을 수행할 수도 있습니다. 이 경우 번역을 수행하기 위해 maketrans()가 필요하지 않습니다. Code # 2: layouttrans()가 없는 번역을 위한 코드입니다.
# Python3 데모 코드
# 번역 없음
# maketrans ( )
# 표시 사양
# ASCII 사용
테이블 = { <코드 클래스 = "값"> 119 <코드 클래스 = "일반">: <코드 클래스 = "값"> 103 <코드 클래스 = "일반">, <코드 클래스 = "값"> 121 <코드 클래스 = "일반">: <코드 클래스 = "값"> 102 < 코드 클래스 = "일반">, <코드 클래스 = "값"> 117 <코드 클래스 = "일반">: <코드 클래스 = "color1"> 없음 <코드 클래스 = "일반">}
<코드 클래스 = "comments"> # 대상 문자열
trg = "weeksyourweeks"
# 원본 줄 인쇄
print ( "번역하기 전의 문자열은:" , end <코드 클래스 ="키워드 "> = <코드 클래스 ="일반 ">" ")
인쇄 (trg)
# 번역 사용( ) 번역합니다.
print ( "번역 후 문자열 is:" , end = " ")
인쇄 (trg.translate(표))
출력: 번역 전의 문자열은 다음과 같습니다. weekyourweeks 번역 후의 문자열은 다음과 같습니다. pythonengineering 응용 프로그램: 대부분의 경우 코딩이나 개발 중에 오류가 발생할 수 있습니다. 이러한 기능은 오류를 교체하고 수정할 수 있는 간단하고 빠른 방법을 제공하며 잠재적으로 많은 시간을 절약할 수 있습니다.
Shop
Best Python online courses for 2022 $FREE
Best laptop for Excel $
Best laptop for Solidworks $399+
Best laptop for Roblox $399+
Best computer for crypto mining $499+
Best laptop for Sims 4 $
Best laptop for Zoom $499
Best laptop for Minecraft $590
Latest questions
PythonStackOverflow
Common xlabel/ylabel for matplotlib subplots
1947 answers
PythonStackOverflow
Check if one list is a subset of another in Python
1173 answers
PythonStackOverflow
How to specify multiple return types using type-hints
1002 answers
PythonStackOverflow
Printing words vertically in Python
909 answers
PythonStackOverflow
Python Extract words from a given string
798 answers
PythonStackOverflow
Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?
606 answers
PythonStackOverflow
Python os.path.join () method
384 answers
PythonStackOverflow
Flake8: Ignore specific warning for entire file
360 answers
Wiki
Python | How to copy data from one Excel sheet to another
Common xlabel/ylabel for matplotlib subplots
Check if one list is a subset of another in Python
How to specify multiple return types using type-hints
Printing words vertically in Python
Python Extract words from a given string
Cyclic redundancy check in Python
Finding mean, median, mode in Python without libraries
Python add suffix / add prefix to strings in a list
Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?
Python - Move item to the end of the list
Python - Print list vertically
|