###### tags: `網路爬蟲`
# *2022/05/20 網路爬蟲 HW03*
## 題目:

## 引用模組程式碼:
```
#模組名稱:Create_Module
def function_1(value_1,value_2=10):
answer = 0
for i in range(value_1,value_2+1,1):
answer = answer + i
return answer
def function_2(str):
str_rev = str[len(str)::-1]
if str == str_rev:
return True
else:
return False
```
## 主程式:
```
import Create_Module as CM
print(CM.function_1(2))
print(CM.function_1(6,20))
print(CM.function_2('船上女子叫子女上船'))
print(CM.function_2('MadaM'))
print(CM.function_2('python'))
```
## 輸出結果:


```
with open('Poetry.txt', 'w', encoding='utf-8') as file:
file.write('杜秋娘【金縷衣】\n\n勸君莫惜金縷衣\n勸君惜取少年時\n花開堪折直須折\n莫待無花空折枝')
f = open('Poetry.txt', 'r', encoding='utf-8')
print(f.read())
f.close()
```


```
import json
my_dict = {
'學員':{
'學號':543,
'姓名':'王大明',
},
'課程':[
{
'課程名稱':'Python程式設計',
'成績':90
},
{
'課程名稱':'JavaScript網頁程式設計',
'成績':80
}
]
}
with open('output.txt', 'w', encoding='utf-8') as f:
json.dump(my_dict, f, ensure_ascii=False)
with open('output.txt', 'r', encoding='utf-8') as f:
d = json.load(f)
print(json.dumps(d, indent=4, ensure_ascii=False))
```
## 輸出結果:


```
while True:
try:
x = int(input('x='))
break
except Exception:
print('輸入內容必須為整數,請重新輸入')
while True:
try:
y = int(input('y='))
break
except Exception:
print('輸入內容必須為整數,請重新輸入')
print('x+y=%d' %(x+y))
```
## 輸出結果:

