"함수 startsWith()"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
7번째 줄: 7번째 줄:
[[분류: JavaScript]]
[[분류: JavaScript]]
{{참고|자바스크립트 startsWith()}}
{{참고|자바스크립트 startsWith()}}
<source lang='JavaScript'>
<syntaxhighlight lang='JavaScript'>
var str = "Hello world!";
var str = "Hello world!";
console.log( str.startsWith("Hello") ); // true
console.log( str.startsWith("Hello") ); // true
13번째 줄: 13번째 줄:
console.log( str.startsWith("ll") ); // false
console.log( str.startsWith("ll") ); // false
console.log( str.startsWith("ll", 2) ); // true
console.log( str.startsWith("ll", 2) ); // true
</source>
</syntaxhighlight>


==Python==
==Python==
[[분류: Python]]
[[분류: Python]]
{{참고|파이썬 startswith()}}
{{참고|파이썬 startswith()}}
<source lang='Python'>
<syntaxhighlight lang='Python'>
str = 'Hello world!'
str = 'Hello world!'
print( str.startswith( 'Hello' ) ) # True
print( str.startswith( 'Hello' ) ) # True
26번째 줄: 26번째 줄:
print( str.startswith( 'Hell', 0, 3 ) ) # False
print( str.startswith( 'Hell', 0, 3 ) ) # False
print( str.startswith( 'Hell', 0, 4 ) ) # True
print( str.startswith( 'Hell', 0, 4 ) ) # True
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
* [[함수 endsWith()]]
* [[함수 endsWith()]]

2020년 11월 2일 (월) 02:33 판

1 개요

startsWith()
startswith()

2 JavaScript

var str = "Hello world!";
console.log( str.startsWith("Hello") ); // true
console.log( str.startsWith("He") ); // true
console.log( str.startsWith("ll") ); // false
console.log( str.startsWith("ll", 2) ); // true

3 Python

str = 'Hello world!'
print( str.startswith( 'Hello' ) ) # True
print( str.startswith( 'He' ) ) # True
print( str.startswith( 'll' ) ) # False
print( str.startswith( 'll', 2 ) ) # True
print( str.startswith( 'Hell', 0, 3 ) ) # False
print( str.startswith( 'Hell', 0, 4 ) ) # True

4 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}