Python 문자열 조작
#Python
'' '1. ' ''
#strcpy( sStr1, sStr2)
sStr1 = 'strcpy'
sStr2 = sStr1
sStr1 = 'strcpy2'
print sStr2
'' '2. ' ''
#strcat( sStr1, sStr2)
sStr1 = 'strcat'
sStr2 = 'append'
sStr1 + = sStr2
print sStr1
'' '3. ' ''
#strchr( sStr1, sStr2)
sStr1 = 'strchr'
sStr2 = 'r'
nPos = sStr1. index( sStr2)
print nPos
'' '4. ' ''
#strcmp( sStr1, sStr2)
sStr1 = 'strchr'
sStr2 = 'strch'
print cmp( sStr1, sStr2)
'' '5. ' ''
#strspn( sStr1, sStr2)
sStr1 = '12345678'
sStr2 = '456'
#sStr1 and chars both in sStr1 and sStr2
print len( sStr1 and sStr2)
'' '6. ' ''
#strlen( sStr1)
sStr1 = 'strlen'
print len( sStr1)
'' '7. ' ''
#strlwr( sStr1)
sStr1 = 'JCstrlwr'
sStr1 = sStr1. upper( )
print sStr1
'' '8. ' ''
#strncat( sStr1, sStr2, n)
sStr1 = '12345'
sStr2 = 'abcdef'
n = 3
sStr1 + = sStr2[ 0: n]
print sStr1
'' '9. ' ''
#strncmp( sStr1, sStr2, n)
sStr1 = '12345'
sStr2 = '123bc'
n = 3
print cmp( sStr1[ 0: n] , sStr2[ 0: n] )
'' '10. ' ''
#strncpy( sStr1, sStr2, n)
sStr1 = ''
sStr2 = '12345'
n = 3
sStr1 = sStr2[ 0: n]
print sStr1
'' '11. , ' ''
#stricmp( sStr1, sStr2)
sStr1 = 'abcefg'
sStr2 = 'ABCEFG'
print cmp( sStr1. upper( ) , sStr2. upper( ) )
'' '12. n ' ''
#strnset( sStr1, ch, n)
sStr1 = '12345'
ch = 'r'
n = 3
sStr1 = n * ch + sStr1[ 3: ]
print sStr1
'' '13. ' ''
#strpbrk( sStr1, sStr2)
sStr1 = 'cekjgdklab'
sStr2 = 'gka'
nPos = - 1
for c in sStr1:
if c in sStr2:
nPos = sStr1. index( c)
break
print nPos
'' '14. ' ''
#strrev( sStr1)
sStr1 = 'abcdefg'
sStr1 = sStr1[ : : - 1]
print sStr1
'' '15. ' ''
#strstr( sStr1, sStr2)
sStr1 = 'abcdefg'
sStr2 = 'cde'
print sStr1. find( sStr2)
'' '16. ' ''
#strtok( sStr1, sStr2)
sStr1 = 'ab,cde,fgh,ijk'
sStr2 = ','
sStr1 = sStr1[ sStr1. find( sStr2) + 1: ]
print sStr1
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Docker를 사용한 React 및 .NET Core 6.0 샘플 프로젝트 - 1부이 기사에서는 Entity Framework Core Code First 접근 방식을 사용하는 ASP.NET Core 6.0 WEP API의 CRUD(만들기, 읽기, 업데이트 및 삭제) 작업에 대해 설명합니다. 웹 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.