質問編集履歴

2

インデントを--->のような表現から<code>を用いた表現に変更しました。

2020/08/17 22:19

投稿

BuhKeil
BuhKeil

スコア34

test CHANGED
File without changes
test CHANGED
@@ -94,6 +94,8 @@
94
94
 
95
95
  # データを受け取る(サーバ側 server.py)のmicro pythonのコード
96
96
 
97
+ ```ここに言語を入力
98
+
97
99
  from datetime import datetime
98
100
 
99
101
  import socket
@@ -108,27 +110,29 @@
108
110
 
109
111
  with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
110
112
 
111
- --->s.bind(("127.0.0.1", 50755))
113
+ s.bind(("127.0.0.1", 50755))
112
114
 
113
- --->s.listen(1)
115
+ s.listen(1)
114
116
 
115
- --->while True:
117
+ while True:
116
118
 
117
- ------->conn, addr = s.accept()
119
+ conn, addr = s.accept()
118
120
 
119
- ------->with conn:
121
+ with conn:
120
122
 
121
- ----------->while True:
123
+ while True:
122
124
 
123
- --------------->data = conn.recv(1024)
125
+ data = conn.recv(1024)
124
126
 
125
- --------------->if not data:
127
+ if not data:
126
128
 
127
- ------------------->break
129
+ break
128
130
 
129
- --------------->print("data: ", data, "addr", addr)
131
+ print("data: ", data, "addr", addr)
130
132
 
131
- --------------->conn.sendall(b"Receive: " + data)
133
+ conn.sendall(b"Receive: " + data)
134
+
135
+ ```
132
136
 
133
137
 
134
138
 

1

インデントを'---->"の表示から、<code>を用いた表現に変更しました。

2020/08/17 22:19

投稿

BuhKeil
BuhKeil

スコア34

test CHANGED
File without changes
test CHANGED
@@ -22,6 +22,8 @@
22
22
 
23
23
 
24
24
 
25
+ ```micropython
26
+
25
27
  import machine
26
28
 
27
29
  import utime
@@ -42,49 +44,51 @@
42
44
 
43
45
  while True:
44
46
 
45
- --->bme = bme280.BME280(i2c=i2c)
47
+ bme = bme280.BME280(i2c=i2c)
46
48
 
47
49
 
48
50
 
49
- --->temp_bme280 = bme.temperature
51
+ temp_bme280 = bme.temperature
50
52
 
51
- --->buf += str(temp_bme280) + "\n"
53
+ buf += str(temp_bme280) + "\n"
52
54
 
53
- --->hum_bme280 = bme.humidity
55
+ hum_bme280 = bme.humidity
54
56
 
55
- --->pres_bme280 = bme.pressure
57
+ pres_bme280 = bme.pressure
56
58
 
57
59
 
58
60
 
59
- --->print("[BME280] Temperature: " + str(temp_bme280))
61
+ print("[BME280] Temperature: " + str(temp_bme280))
60
62
 
61
- --->print("[BME280] Humidity: " + str(hum_bme280))
63
+ print("[BME280] Humidity: " + str(hum_bme280))
62
64
 
63
- --->print("[BME280] Pressure: " + str(pres_bme280), end="\n")
65
+ print("[BME280] Pressure: " + str(pres_bme280), end="\n")
64
66
 
65
67
 
66
68
 
67
- --->with usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM) as client:
69
+ with usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM) as client:
68
70
 
69
- ------->client.connect(("192.168.0.4", 50755))
71
+ client.connect(("192.168.0.4", 50755))
70
72
 
71
- ------->client.sendall(buf.encode())
73
+ client.sendall(buf.encode())
72
74
 
73
- ------->data = client.recv(1024).decode()
75
+ data = client.recv(1024).decode()
74
76
 
75
- ------->print(repr(data))
77
+ print(repr(data))
76
78
 
77
79
 
78
80
 
79
- --->print(buf)
81
+ print(buf)
80
82
 
81
- --->line += 1
83
+ line += 1
82
84
 
83
- --->utime.sleep(5)
85
+ utime.sleep(5)
84
86
 
85
87
 
86
88
 
87
89
  fp.close()
90
+
91
+ ```
88
92
 
89
93
 
90
94