mirror of
https://github.com/aykhans/recursive-python-file.git
synced 2025-04-21 09:40:01 +00:00
.
This commit is contained in:
commit
af9a64cd9e
28
who_am_i.py
Normal file
28
who_am_i.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
start = 1
|
||||||
|
stop = 10
|
||||||
|
t = 1
|
||||||
|
import os
|
||||||
|
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
|
||||||
|
if t:
|
||||||
|
with open(__file__, 'r+') as d:
|
||||||
|
data_cnt = d.readline()
|
||||||
|
first_space = data_cnt.rfind(' ')
|
||||||
|
data_cnt = data_cnt[:first_space+1] + str(int(data_cnt[first_space+1:-1]) + 1) + '\n'
|
||||||
|
|
||||||
|
all_data = d.read()
|
||||||
|
all_data = data_cnt + all_data
|
||||||
|
first_point = all_data.find('#')
|
||||||
|
second_point = all_data.find('#', first_point+1)
|
||||||
|
d.seek(0)
|
||||||
|
|
||||||
|
if all_data.find('if', first_point, second_point+1) == -1:
|
||||||
|
d.write(all_data[:first_point+2] + f"if {start} == stop: t = 0" + all_data[second_point-1:])
|
||||||
|
|
||||||
|
else:
|
||||||
|
d.write(all_data[:second_point-1] + f"\nelif {start} == stop: t = 0" + all_data[second_point-1:])
|
||||||
|
|
||||||
|
os.system('python ' + __file__)
|
Loading…
x
Reference in New Issue
Block a user