파이썬에서 일반적으로 사용되는 문자열
파이썬을 배울 때 일반적으로 사용되는 문자열을 정리하겠습니다. 실제로는 더 많은 예가 있습니다.
1.eval(str)
print("12+3")print(eval("12+3"))
우리가 일반적으로 인쇄에 입력하는 문자열이 바로 출력되며, eval(str)은 문자열 str을 유효한 표현식으로 처리하여 계산 결과를 반환할 수 있습니다
(무료 학습 추천: python 동영상 튜토리얼)
2.len(str)
print(len("man"))print(len("man "))
len(str)은 문자열의 길이(문자 수)를 반환합니다. 공백도 문자
3.lower(str)
str1 = "MAN"print(str1.lower())
lower(str) 대문자를 소문자로 변환합니다(문자열 재생성과 동일)
4.upper(str)
str2 = "man"print(str2.upper())
upper(str)는 소문자를 대문자로 변환하고(문자열을 재생성하는 것과 동일) lower()
5.swapcase()
str3 ="so that WE LIKe close FriENds"print(str3.swapcase())
의 반대입니다. swapcase()는 문자열을 변환합니다. 소문자는 다음과 같습니다. 대문자이고 대문자는 소문자입니다.
6.ljust(width[,filch])
str4 = "man"print(str4.ljust(40, "*"))
ljust(width[,filch])는 지정된 너비로 왼쪽 정렬된 문자열을 반환합니다. filch는 채우기 문자입니다. , 기본 공백
7.rjust (width[, filch]) 마찬가지로 오른쪽 정렬
8.center (width, filch)
str5 = "man!"print(str5.center(40, "*"))
center (width, filch) return 중앙 지정 string, 기본 공백 채우기
9.zfill(width)
str6 = "man!"print(str6.zfill(40))
zfill(width)는 width 길이의 문자열을 반환하고 원래 문자열은 오른쪽 정렬되며 앞 부분은 0으로 채워집니다.
10.count(str[,start][,end])
str7 = "so that we like close close friends"print(str7.count("close"))print(str7.count("close", 22, len(str7)))
count(str[,start][,end])는 문자열에서 str의 발생 횟수를 반환합니다. 범위를 지정하고 기본값은 끝까지
11.find(str[,strat][,end])
str7 = "so that we like close close friends"print(str7.find("close"))print(str7.find("man"))
find(str[,strat][,end])는 왼쪽부터 감지합니다. str 문자열에 검색된 문자열이 포함되어 있는지 여부를 오른쪽으로 지정하면 범위를 지정할 수 있습니다. 기본값은 처음부터 끝까지이며 결과는 첫 번째 항목의 시작 첨자이며 반환되지 않습니다. -1
12.title()
각 단어의str7 = "so that we like close close friends"print(str7.title())
title() 첫 글자는 대문자입니다
13.capitalize()
str7 = "tHAtwelikEcLOSEclosefRIEnds"print(str7.capitalize())
capitalize()첫 글자는 대문자, 나머지는 소문자
14.index(str , start=0, end=len(str)
str7 = "so that we like close close friends"print(str7.index("we"))print(str7.index("is"))
index(str, start=0, end=len(str))은 find와 동일하지만 str이 존재하지 않으면 예외가 보고됩니다.
15.lstrip()
str8 = " a good man!"str9 = "***** a good man!"print(str8.lstrip())print(str9.lstrip("*"))
lstrip() 문자열 왼쪽에서 지정된 문자를 가로채는 것이 기본값입니다. 가로채기 매개변수를 작성한 후에는 공백이 표시되지 않는 것을 볼 수 있습니다. 아직 배우는 중입니다. 실수가 있으면 수정해 주세요.
많이 무료 학습 권장 사항을 보려면python tutorial(동영상)을 방문하세요.
위 내용은 파이썬에서 흔히 사용되는 문자열과 그 연산을 살펴보겠습니다.의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

Arraysinpython, 특히 비밀 복구를위한 ArecrucialInscientificcomputing.1) theaRearedFornumericalOperations, DataAnalysis 및 MachinELearning.2) Numpy'SimplementationIncensuressuressurations thanpythonlists.3) arraysenablequick

Pyenv, Venv 및 Anaconda를 사용하여 다양한 Python 버전을 관리 할 수 있습니다. 1) PYENV를 사용하여 여러 Python 버전을 관리합니다. Pyenv를 설치하고 글로벌 및 로컬 버전을 설정하십시오. 2) VENV를 사용하여 프로젝트 종속성을 분리하기 위해 가상 환경을 만듭니다. 3) Anaconda를 사용하여 데이터 과학 프로젝트에서 Python 버전을 관리하십시오. 4) 시스템 수준의 작업을 위해 시스템 파이썬을 유지하십시오. 이러한 도구와 전략을 통해 다양한 버전의 Python을 효과적으로 관리하여 프로젝트의 원활한 실행을 보장 할 수 있습니다.

Numpyarrayshaveseveraladvantagesstandardpythonarrays : 1) thearemuchfasterduetoc 기반 간증, 2) thearemorememory-refficient, 특히 withlargedatasets 및 3) wepferoptizedformationsformationstaticaloperations, 만들기, 만들기

어레이의 균질성이 성능에 미치는 영향은 이중입니다. 1) 균질성은 컴파일러가 메모리 액세스를 최적화하고 성능을 향상시킬 수 있습니다. 2) 그러나 유형 다양성을 제한하여 비 효율성으로 이어질 수 있습니다. 요컨대, 올바른 데이터 구조를 선택하는 것이 중요합니다.

tocraftexecutablepythonscripts, 다음과 같은 비스트 프랙티스를 따르십시오 : 1) 1) addashebangline (#!/usr/bin/envpython3) tomakethescriptexecutable.2) setpermissionswithchmod xyour_script.py.3) organtionewithlarstringanduseifname == "__"

numpyarraysarebetterfornumericaloperations 및 multi-dimensionaldata, mumemer-efficientArrays

numpyarraysarebetterforheavynumericalcomputing, whilearraymoduleisiMoresuily-sportainedprojectswithsimpledatatypes.1) numpyarraysofferversatively 및 formanceforgedatasets 및 complexoperations.2) Thearraymoduleisweighit 및 ep

ctypesallowscreatingandmanipulatingC-stylearraysinPython.1)UsectypestointerfacewithClibrariesforperformance.2)CreateC-stylearraysfornumericalcomputations.3)PassarraystoCfunctionsforefficientoperations.However,becautiousofmemorymanagement,performanceo


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

PhpStorm 맥 버전
최신(2018.2.1) 전문 PHP 통합 개발 도구

Atom Editor Mac 버전 다운로드
가장 인기 있는 오픈 소스 편집기

WebStorm Mac 버전
유용한 JavaScript 개발 도구

SecList
SecLists는 최고의 보안 테스터의 동반자입니다. 보안 평가 시 자주 사용되는 다양한 유형의 목록을 한 곳에 모아 놓은 것입니다. SecLists는 보안 테스터에게 필요할 수 있는 모든 목록을 편리하게 제공하여 보안 테스트를 더욱 효율적이고 생산적으로 만드는 데 도움이 됩니다. 목록 유형에는 사용자 이름, 비밀번호, URL, 퍼징 페이로드, 민감한 데이터 패턴, 웹 셸 등이 포함됩니다. 테스터는 이 저장소를 새로운 테스트 시스템으로 간단히 가져올 수 있으며 필요한 모든 유형의 목록에 액세스할 수 있습니다.

에디트플러스 중국어 크랙 버전
작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음
