回答編集履歴

1

追記、修正

2018/11/05 06:59

投稿

can110
can110

スコア38266

test CHANGED
@@ -1,4 +1,4 @@
1
- 単に`re.match('東京都',文字列`でよいです。あるいは`str.startswith`でも可能です。
1
+ 単に`r = re.match('東京都',文字列`->`print(r.group(0))`でよいです。
2
2
 
3
3
  ```Python
4
4
 
@@ -8,8 +8,14 @@
8
8
 
9
9
  print(s)
10
10
 
11
- if re.match('東京都',s):
11
+ r = re.match('東京都',s)
12
+
13
+ if r is not None:
12
14
 
13
15
  print('match')
14
16
 
17
+ print(r.group(0))
18
+
15
19
  ```
20
+
21
+ あ、python2.x系コードが原因のようだったようですね。