-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathread_write.py
46 lines (35 loc) · 978 Bytes
/
read_write.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 19 12:53:26 2020
@author: chans
"""
def set_to(axis,value):
with open("globals.txt", "r") as file:
data = file.read()
parsed_data = data.split()
x = parsed_data[2]
r = parsed_data[5]
z = parsed_data[8]
if axis == "x":
x = value
elif axis == "r":
r = value
elif axis == "z":
z = value
with open("globals.txt", "w") as file:
file.write("x = %s\n"%x)
file.write("r = %s\n"%r)
file.write("z = %s"%z)
def get(axis):
with open("globals.txt", "r") as file:
data = file.read()
parsed_data = data.split()
x = parsed_data[2]
r = parsed_data[5]
z = parsed_data[8]
if axis == "x":
return x
elif axis == "r":
return r
elif axis == "z":
return z